Skip to content

Commit afded3d

Browse files
committed
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. Closes GH-21692
1 parent 391ec27 commit afded3d

File tree

1 file changed

+5
-31
lines changed

1 file changed

+5
-31
lines changed

ext/openssl/tests/gh21031.phpt

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,11 @@ $serverCode = <<<'CODE'
2323
$server = stream_socket_server('tls://127.0.0.1:0', $errno, $errstr, $serverFlags, $ctx);
2424
phpt_notify_server_start($server);
2525
26-
$conn = stream_socket_accept($server, 3);
27-
fclose($conn);
28-
29-
phpt_wait();
30-
CODE;
31-
32-
$proxyCode = <<<'CODE'
33-
$flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
34-
$server = stream_socket_server("tcp://127.0.0.1:0", $errornum, $errorstr, $flags);
35-
phpt_notify_server_start($server);
36-
37-
$upstream = stream_socket_client("tcp://{{ ADDR }}", $errornum, $errorstr, 30, STREAM_CLIENT_CONNECT);
38-
stream_set_blocking($upstream, false);
39-
40-
$conn = stream_socket_accept($server);
41-
stream_set_blocking($conn, true);
42-
43-
// reading CONNECT request headers
44-
while (($line = fgets($conn)) !== false) {
45-
if (rtrim($line) === '') break; // empty line means end of headers
26+
$conn = stream_socket_accept($server, 10);
27+
if ($conn) {
28+
fclose($conn);
4629
}
4730
48-
// successful CONNECT response
49-
fwrite($conn, "HTTP/1.0 200 Connection established\r\n\r\n");
50-
51-
fclose($conn);
52-
fclose($upstream);
5331
phpt_wait();
5432
CODE;
5533

@@ -67,15 +45,11 @@ $clientCode = <<<'CODE'
6745
6846
var_dump(@file_get_contents("https://cs.php.net/", false, $clientCtx));
6947
70-
phpt_notify('proxy');
71-
phpt_notify('server');
48+
phpt_notify();
7249
CODE;
7350

7451
include 'ServerClientTestCase.inc';
75-
ServerClientTestCase::getInstance()->run($clientCode, [
76-
'server' => $serverCode,
77-
'proxy' => $proxyCode,
78-
]);
52+
ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
7953
?>
8054
--EXPECT--
8155
bool(false)

0 commit comments

Comments
 (0)