Skip to content

Commit c2553a2

Browse files
authored
sapi/fcgi: update listen queue size handling. (#13939)
the default backlog does not necessarily need to be higher than 128, however for systems like haiku it s mor benefitial to be actually lower.
1 parent 4a0ec3d commit c2553a2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sapi/cgi/cgi_main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1918,10 +1918,17 @@ consult the installation file that came with this distribution, or visit \n\
19181918
#endif
19191919

19201920
if (bindpath) {
1921-
int backlog = 128;
1921+
int backlog = MIN(SOMAXCONN, 128);
19221922
if (getenv("PHP_FCGI_BACKLOG")) {
19231923
backlog = atoi(getenv("PHP_FCGI_BACKLOG"));
19241924
}
1925+
if (backlog < -1 || backlog > SOMAXCONN) {
1926+
fprintf(stderr, "Invalid backlog %d, needs to be between -1 and %d\n", backlog, SOMAXCONN);
1927+
#ifdef ZTS
1928+
tsrm_shutdown();
1929+
#endif
1930+
return FAILURE;
1931+
}
19251932
fcgi_fd = fcgi_listen(bindpath, backlog);
19261933
if (fcgi_fd < 0) {
19271934
fprintf(stderr, "Couldn't create FastCGI listen socket on port %s\n", bindpath);

0 commit comments

Comments
 (0)