From 9579e726fb8187c0ac8bf49181a160b0768d51c5 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 9 Apr 2026 18:50:58 +0200 Subject: [PATCH] Simplify gh21031.phpt and solve flakiness stream_socket_accept($server, 3) would frequently run into a race-condition where the call would timeout and return false, triggering an exception when calling fclose(false) and terminating the process. This would break the phpt_notify() call in the main process due to a broken pipe. Increase the timeout to solve this. Furthermore, remove the proxy in the test that is not necessary to trigger the original bug solved in 7782b88. --- ext/openssl/tests/gh21031.phpt | 36 +++++----------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/ext/openssl/tests/gh21031.phpt b/ext/openssl/tests/gh21031.phpt index 55694bf7676e8..25bdb385a7917 100644 --- a/ext/openssl/tests/gh21031.phpt +++ b/ext/openssl/tests/gh21031.phpt @@ -23,33 +23,11 @@ $serverCode = <<<'CODE' $server = stream_socket_server('tls://127.0.0.1:0', $errno, $errstr, $serverFlags, $ctx); phpt_notify_server_start($server); - $conn = stream_socket_accept($server, 3); - fclose($conn); - - phpt_wait(); -CODE; - -$proxyCode = <<<'CODE' - $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; - $server = stream_socket_server("tcp://127.0.0.1:0", $errornum, $errorstr, $flags); - phpt_notify_server_start($server); - - $upstream = stream_socket_client("tcp://{{ ADDR }}", $errornum, $errorstr, 30, STREAM_CLIENT_CONNECT); - stream_set_blocking($upstream, false); - - $conn = stream_socket_accept($server); - stream_set_blocking($conn, true); - - // reading CONNECT request headers - while (($line = fgets($conn)) !== false) { - if (rtrim($line) === '') break; // empty line means end of headers + $conn = stream_socket_accept($server, 10); + if ($conn) { + fclose($conn); } - // successful CONNECT response - fwrite($conn, "HTTP/1.0 200 Connection established\r\n\r\n"); - - fclose($conn); - fclose($upstream); phpt_wait(); CODE; @@ -67,15 +45,11 @@ $clientCode = <<<'CODE' var_dump(@file_get_contents("https://cs.php.net/", false, $clientCtx)); - phpt_notify('proxy'); - phpt_notify('server'); + phpt_notify(); CODE; include 'ServerClientTestCase.inc'; -ServerClientTestCase::getInstance()->run($clientCode, [ - 'server' => $serverCode, - 'proxy' => $proxyCode, -]); +ServerClientTestCase::getInstance()->run($clientCode, $serverCode); ?> --EXPECT-- bool(false)