]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: await portfile to be complete
authorStefan Eissing <stefan@eissing.org>
Sat, 31 May 2025 11:31:03 +0000 (13:31 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 31 May 2025 11:58:18 +0000 (13:58 +0200)
When running under load, a started server may not produce a valid portfile
before the runner starts reading it. If the read is not successful, wait
for 100ms and try again, timing out after 15 seconds.

Fixes #17492
Closes #17495

tests/servers.pm

index 9389c6fa9eed08822af83fd0e705e5f9c83ec5f6..e9c7f647f23662415cad9510aab0a14b976ca47f 100644 (file)
@@ -29,6 +29,7 @@
 package servers;
 
 use IO::Socket;
+use Time::HiRes;
 use strict;
 use warnings;
 
@@ -1145,8 +1146,16 @@ sub runhttpserver {
 
     # where is it?
     my $port = 0;
-    if(!$port_or_path) {
+    my $waits = 0;
+    # wait at max 15 seconds to the port file to become valid
+    while(!$port_or_path && ($waits < (15 * 10))) {
         $port = $port_or_path = pidfromfile($portfile);
+        Time::HiRes::sleep(0.1) unless $port_or_path;
+        ++$waits;
+    }
+    if(!$port) {
+        logmsg "RUN: failed waiting for server to produce port file $portfile\n";
+        return (1, 0, 0, 0);
     }
 
     if($verb) {