From: Stefan Eissing Date: Sat, 31 May 2025 11:31:03 +0000 (+0200) Subject: tests: await portfile to be complete X-Git-Tag: curl-8_14_1~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=759d33a25c33820c607f389718e2c212c0f653a1;p=thirdparty%2Fcurl.git tests: await portfile to be complete 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 --- diff --git a/tests/servers.pm b/tests/servers.pm index 9389c6fa9e..e9c7f647f2 100644 --- a/tests/servers.pm +++ b/tests/servers.pm @@ -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) {