[php-src] PR #24230: Fix GH-24229: fcgi_close() passes shutdown() a literal 1
| From: | mpyw | Date: | Fri, 09 Oct 2026 20:39:39 +0000 |
| Subject: | [php-src] PR #24230: Fix GH-24229: fcgi_close() passes shutdown() a literal 1 | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-39301@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/24230
Author: mpyw
Fixes GH-24229.
The quoted description below, and the checks it describes, were done with an LLM (Claude). I
reviewed them.
>
fcgi_close() half-closed the connection with µ ß`'š|H 9‹Æ
> shutdown(req->fd, 1), meaning SHUT_WR, as the
> comment after it says. Every platform PHP supports uses 1 for
> SHUT_WR, but POSIX does not fix the value. WASI uses 2, and 1 is
> SHUT_RD there.
>
> With the read side shut, the drain loop ended at once. close()
> could then run with the web server's last FCGI_STDIN unread,
> and Linux reset the connection. That discarded the response before the web server read it.
>
> This uses SHUT_WR, which
> <sys/socket.h> already provides there. The
> _WIN32 branch is left as is: 1 is
> SD_SEND, which is right on Windows.
>
> There is no test: on the supported platforms, SHUT_WR is 1, so
> nothing changes. I checked that in a build of this branch, configured with
> --disable-all --enable-cli --enable-cgi --enable-fpm on Debian
> trixie. sapi/cgi/tests and á–ï5
> L�xÿÆ\é(Õusapi/fpm/tests give the same results with and without this change: 132
> passed, 26 skipped, and the same 2 failures, which come from running them as root in a container.
>
> The fix itself was checked with php-cgi built for
> wasm32-wasip1, in FastCGI mode on wazero. On Linux, 10 of 600
> requests failed before it, and none after.
>
> This targets PHP-8.4 as the lowest branch with bug fixes. I am happy to retarget it to master
> if you see this as a portability change rather than a bug fix.