Skip to content

Commit 0e16e29

Browse files
committed
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
1 parent 44e8301 commit 0e16e29

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ PHP NEWS
198198
SYN packets from the client. (David Carlier)
199199
. Added the SO_EXCLBIND constant for exclusive socket binding on illumos/solaris.
200200
(David Carlier)
201+
. Updated the socket_create_listen backlog argument default value to SOMAXCONN.
202+
(David Carlier)
201203

202204
- SNMP:
203205
. Removed the deprecated inet_ntoa call support. (David Carlier)

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ PHP 8.4 UPGRADE NOTES
387387
. posix_isatty now sets the error number when the file descriptor/stream argument
388388
is invalid.
389389

390+
- Sockets:
391+
. Parameter $backlog of socket_create_listen() now has a default value of SOMAXCONN.
392+
Previously, it was 128.
393+
390394
- SPL:
391395
. SplPriorityQueue::insert() and SplPriorityQueue::recoverFromCorruption()
392396
now has a tentative return type of true

ext/sockets/sockets.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ ZEND_GET_MODULE(sockets)
220220
static bool php_open_listen_sock(php_socket *sock, int port, int backlog) /* {{{ */
221221
{
222222
struct sockaddr_in la = {0};
223-
struct hostent *hp;
223+
struct hostent *hp;
224224

225225
#ifndef PHP_WIN32
226226
if ((hp = php_network_gethostbyname("0.0.0.0")) == NULL) {
@@ -641,7 +641,7 @@ PHP_FUNCTION(socket_select)
641641
PHP_FUNCTION(socket_create_listen)
642642
{
643643
php_socket *php_sock;
644-
zend_long port, backlog = 128;
644+
zend_long port, backlog = SOMAXCONN;
645645

646646
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l", &port, &backlog) == FAILURE) {
647647
RETURN_THROWS();
@@ -764,7 +764,7 @@ PHP_FUNCTION(socket_listen)
764764
{
765765
zval *arg1;
766766
php_socket *php_sock;
767-
zend_long backlog = 0;
767+
zend_long backlog = 0;
768768

769769
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l", &arg1, socket_ce, &backlog) == FAILURE) {
770770
RETURN_THROWS();

ext/sockets/sockets.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,7 @@ final class AddressInfo
18851885

18861886
function socket_select(?array &$read, ?array &$write, ?array &$except, ?int $seconds, int $microseconds = 0): int|false {}
18871887

1888-
function socket_create_listen(int $port, int $backlog = 128): Socket|false {}
1888+
function socket_create_listen(int $port, int $backlog = SOMAXCONN): Socket|false {}
18891889

18901890
function socket_accept(Socket $socket): Socket|false {}
18911891

ext/sockets/sockets_arginfo.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)