[php-src] master: ext/sockets: socket_create_listen update.

From: Date: Wed, 10 Apr 2024 17:40:09 +0000
Subject: [php-src] master: ext/sockets: socket_create_listen update.
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-128060@lists.php.net to get a copy of this message
Author: David Carlier (devnexen) Date: 2024-04-10T18:39:38+01:00 Commit: https://github.com/php/php-src/commit/0e16e29b40e1d902e1cd06134b5f023a9fd011d0 Raw diff: https://github.com/php/php-src/commit/0e16e29b40e1d902e1cd06134b5f023a9fd011d0.diff ext/sockets: socket_create_listen update. going from 128 to system's SOMAXCONN by default to be able to increase the queue of connections to be handled. Also, for Haiku SOMAXCONN is only 32. Close GH-13854 Changed paths: M NEWS M UPGRADING M ext/sockets/sockets.c M ext/sockets/sockets.stub.php M ext/sockets/sockets_arginfo.h Diff: diff --git a/NEWS b/NEWS index 0a3c75348ea6..6fcb6b9a92a5 100644 --- a/NEWS +++ b/NEWS @@ -198,6 +198,8 @@ PHP NEWS SYN packets from the client. (David Carlier) . Added the SO_EXCLBIND constant for exclusive socket binding on illumos/solaris. (David Carlier) + . Updated the socket_create_listen backlog argument default value to SOMAXCONN. + (David Carlier) - SNMP: . Removed the deprecated inet_ntoa call support. (David Carlier) diff --git a/UPGRADING b/UPGRADING index 02c2ebafd76b..5366b4216242 100644 --- a/UPGRADING +++ b/UPGRADING @@ -387,6 +387,10 @@ PHP 8.4 UPGRADE NOTES . posix_isatty now sets the error number when the file descriptor/stream argument is invalid. +- Sockets: + . Parameter $backlog of socket_create_listen() now has a default value of SOMAXCONN. + Previously, it was 128. + - SPL: . SplPriorityQueue::insert() and SplPriorityQueue::recoverFromCorruption() now has a tentative return type of true diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 8a15e98c44c3..1de50d9f8878 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -220,7 +220,7 @@ ZEND_GET_MODULE(sockets) static bool php_open_listen_sock(php_socket *sock, int port, int backlog) /* {{{ */ { struct sockaddr_in la = {0}; - struct hostent *hp; + struct hostent *hp; #ifndef PHP_WIN32 if ((hp = php_network_gethostbyname("0.0.0.0")) == NULL) { @@ -641,7 +641,7 @@ PHP_FUNCTION(socket_select) PHP_FUNCTION(socket_create_listen) { php_socket *php_sock; - zend_long port, backlog = 128; + zend_long port, backlog = SOMAXCONN; if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l", &port, &backlog) == FAILURE) { RETURN_THROWS(); @@ -764,7 +764,7 @@ PHP_FUNCTION(socket_listen) { zval *arg1; php_socket *php_sock; - zend_long backlog = 0; + zend_long backlog = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l", &arg1, socket_ce, &backlog) == FAILURE) { RETURN_THROWS(); diff --git a/ext/sockets/sockets.stub.php b/ext/sockets/sockets.stub.php index 502fff2e0f19..00062610b7ea 100644 --- a/ext/sockets/sockets.stub.php +++ b/ext/sockets/sockets.stub.php @@ -1885,7 +1885,7 @@ final class AddressInfo function socket_select(?array &$read, ?array &$write, ?array &$except, ?int $seconds, int $microseconds = 0): int|false {} -function socket_create_listen(int $port, int $backlog = 128): Socket|false {} +function socket_create_listen(int $port, int $backlog = SOMAXCONN): Socket|false {} function socket_accept(Socket $socket): Socket|false {} diff --git a/ext/sockets/sockets_arginfo.h b/ext/sockets/sockets_arginfo.h index 6697db704c70..50c5e114c8ed 100644 --- a/ext/sockets/sockets_arginfo.h +++ b/ext/sockets/sockets_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 98bd7f47a1aa8d1c2cb40bf768115da2633f56fb */ + * Stub hash: 88a8e188f73c18c510eb984586b21109b347f251 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_select, 0, 4, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(1, read, IS_ARRAY, 1) @@ -11,7 +11,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_socket_create_listen, 0, 1, Socket, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, port, IS_LONG, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, backlog, IS_LONG, 0, "128") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, backlog, IS_LONG, 0, "SOMAXCONN") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_socket_accept, 0, 1, Socket, MAY_BE_FALSE)

« previous php.cvs (#128060) next »