mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.2'
* PHP-8.2: Fix cli server blocking on accept when using multiple workers
This commit is contained in:
commit
ec55d341bf
1 changed files with 10 additions and 1 deletions
|
@ -2529,6 +2529,14 @@ static zend_result php_cli_server_ctor(php_cli_server *server, const char *addr,
|
|||
retval = FAILURE;
|
||||
goto out;
|
||||
}
|
||||
// server_sock needs to be non-blocking when using multiple processes. Without it, the first process would
|
||||
// successfully accept the connection but the others would block, causing client sockets of the same select
|
||||
// call not to be handled.
|
||||
if (SUCCESS != php_set_sock_blocking(server_sock, 0)) {
|
||||
php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "Failed to make server socket non-blocking");
|
||||
retval = FAILURE;
|
||||
goto out;
|
||||
}
|
||||
server->server_sock = server_sock;
|
||||
|
||||
php_cli_server_startup_workers();
|
||||
|
@ -2661,7 +2669,8 @@ static zend_result php_cli_server_do_event_for_each_fd_callback(void *_params, p
|
|||
struct sockaddr *sa = pemalloc(server->socklen, 1);
|
||||
client_sock = accept(server->server_sock, sa, &socklen);
|
||||
if (!ZEND_VALID_SOCKET(client_sock)) {
|
||||
if (php_cli_server_log_level >= PHP_CLI_SERVER_LOG_ERROR) {
|
||||
int err = php_socket_errno();
|
||||
if (err != SOCK_EAGAIN && php_cli_server_log_level >= PHP_CLI_SERVER_LOG_ERROR) {
|
||||
char *errstr = php_socket_strerror(php_socket_errno(), NULL, 0);
|
||||
php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR,
|
||||
"Failed to accept a client (reason: %s)", errstr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue