1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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
This commit is contained in:
David Carlier
2024-03-31 16:07:39 +01:00
parent 44e8301cf6
commit 0e16e29b40
5 changed files with 12 additions and 6 deletions

2
NEWS
View File

@@ -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)

View File

@@ -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

View File

@@ -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();

View File

@@ -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 {}

View File

@@ -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)