Commit 1f1790940a4 for php
commit 1f1790940a4d45ed1f9d3d91a92046c2e45d3345
Author: Weilin Du <weilindu@php.net>
Date: Tue Sep 29 00:24:36 2026 +0800
CI: Fix flacky ext\curl\tests\curl_setopt_ssl.phpt (#23944)
Sometimes, 1 sec in not enough for the service to start.
This test is flacky because of this in my server, also in gh CI:
https://github.com/php/php-src/actions/runs/36204765497/job/108298870351
diff --git a/ext/curl/tests/curl_setopt_ssl.phpt b/ext/curl/tests/curl_setopt_ssl.phpt
index e3b97a3ea73..cc152c9f4f1 100644
--- a/ext/curl/tests/curl_setopt_ssl.phpt
+++ b/ext/curl/tests/curl_setopt_ssl.phpt
@@ -73,8 +73,24 @@ function check_response($response, $clientCertSubject) {
die('failed to start server');
}
try {
- // Give the server time to start
- sleep(1);
+ // Wait until OpenSSL is actually listening before making the first request.
+ $ready = false;
+ for ($i = 0; $i < 100; $i++) {
+ $connection = @stream_socket_client("tcp://127.0.0.1:$port", $errno, $errstr, 0.05);
+ if ($connection !== false) {
+ fclose($connection);
+ $ready = true;
+ break;
+ }
+ if (!proc_get_status($process)['running']) {
+ break;
+ }
+ usleep(50000);
+ }
+ if (!$ready) {
+ stream_set_blocking($pipes[2], false);
+ throw new RuntimeException('OpenSSL server did not start: ' . trim(stream_get_contents($pipes[2])));
+ }
echo "case 1: client cert and key from string\n";
$ch = curl_init("https://127.0.0.1:$port/");