mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
add backlock socket context option for stream_socket_server(),
which had a hardcoded backlog of 5 at two occurrances
This commit is contained in:
parent
b4e1296756
commit
5b277c4da0
@ -157,7 +157,20 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, long namelen, int
|
||||
ERR_RETURN(error_string, error_text, "bind() failed: %s");
|
||||
failed = 1;
|
||||
} else if (flags & STREAM_XPORT_LISTEN) {
|
||||
if (0 != php_stream_xport_listen(stream, 5, &error_text TSRMLS_CC)) {
|
||||
zval **zbacklog = NULL;
|
||||
int backlog = 32;
|
||||
|
||||
if (stream->context && php_stream_context_get_option(stream->context, "socket", "backlog", &zbacklog) == SUCCESS) {
|
||||
zval *ztmp = *zbacklog;
|
||||
|
||||
convert_to_long_ex(&ztmp);
|
||||
backlog = Z_LVAL_P(ztmp);
|
||||
if (ztmp != *zbacklog) {
|
||||
zval_ptr_dtor(&ztmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != php_stream_xport_listen(stream, backlog, &error_text TSRMLS_CC)) {
|
||||
ERR_RETURN(error_string, error_text, "listen() failed: %s");
|
||||
failed = 1;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
|
||||
|
||||
switch (xparam->op) {
|
||||
case STREAM_XPORT_OP_LISTEN:
|
||||
xparam->outputs.returncode = (listen(sock->socket, 5) == 0) ? 0: -1;
|
||||
xparam->outputs.returncode = (listen(sock->socket, xparam->inputs.backlog) == 0) ? 0: -1;
|
||||
return PHP_STREAM_OPTION_RETURN_OK;
|
||||
|
||||
case STREAM_XPORT_OP_GET_NAME:
|
||||
|
Loading…
Reference in New Issue
Block a user