mirror of
https://github.com/curl/curl.git
synced 2026-08-25 16:13:32 +03:00
runtests: assume Time::HiRes, drop Perl Win32 dependency
`Time::HiRes` was already used unconditionally before this patch in
`servers.pm`. This package, and functions used by runtests (`sleep` and
`gettimeofday`) are supported by the minimum Perl version required for
curl:
https://perldoc.perl.org/5.8.0/Time::HiRes
- Drop the `portable_sleep()` wrapper in favor of `Time::HiRes::sleep()`.
- Use `Time::HiRes` unconditionally in `serverhelp.pm`.
- Stop using the `Win32` package where available. It was included
to provide a Windows fallback for `Time::HiRes::sleep()`. It was never
actually called, but the dependency may have loaded `Win32.dll`, which
often appears in failed fork operations in GHA logs.
Ref: a6fed41f6f #5054 #5034
Ref: https://github.com/curl/curl/discussions/14854
Closes #18287
This commit is contained in:
parent
c24d4be057
commit
be01b60ce5
6 changed files with 18 additions and 68 deletions
|
|
@ -51,6 +51,7 @@ BEGIN {
|
||||||
use IPC::Open2;
|
use IPC::Open2;
|
||||||
use Digest::MD5;
|
use Digest::MD5;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
|
use Time::HiRes;
|
||||||
|
|
||||||
use directories;
|
use directories;
|
||||||
|
|
||||||
|
|
@ -484,7 +485,7 @@ sub sendcontrol {
|
||||||
|
|
||||||
for(@a) {
|
for(@a) {
|
||||||
sockfilt $_;
|
sockfilt $_;
|
||||||
portable_sleep($ctrldelay);
|
Time::HiRes::sleep($ctrldelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $log;
|
my $log;
|
||||||
|
|
@ -521,7 +522,7 @@ sub senddata {
|
||||||
# pause between each byte
|
# pause between each byte
|
||||||
for (split(//,$l)) {
|
for (split(//,$l)) {
|
||||||
sockfiltsecondary $_;
|
sockfiltsecondary $_;
|
||||||
portable_sleep($datadelay);
|
Time::HiRes::sleep($datadelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3292,7 +3293,7 @@ while(1) {
|
||||||
logmsg("Sleep for $delay seconds\n");
|
logmsg("Sleep for $delay seconds\n");
|
||||||
my $twentieths = $delay * 20;
|
my $twentieths = $delay * 20;
|
||||||
while($twentieths--) {
|
while($twentieths--) {
|
||||||
portable_sleep(0.05) unless($got_exit_signal);
|
Time::HiRes::sleep(0.05) unless($got_exit_signal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,12 @@ package processhelp;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use Time::HiRes;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use base qw(Exporter);
|
use base qw(Exporter);
|
||||||
|
|
||||||
our @EXPORT = qw(
|
our @EXPORT = qw(
|
||||||
portable_sleep
|
|
||||||
pidfromfile
|
pidfromfile
|
||||||
pidexists
|
pidexists
|
||||||
pidwait
|
pidwait
|
||||||
|
|
@ -42,17 +43,6 @@ BEGIN {
|
||||||
set_advisor_read_lock
|
set_advisor_read_lock
|
||||||
clear_advisor_read_lock
|
clear_advisor_read_lock
|
||||||
);
|
);
|
||||||
|
|
||||||
# portable sleeping needs Time::HiRes
|
|
||||||
eval {
|
|
||||||
no warnings "all";
|
|
||||||
require Time::HiRes;
|
|
||||||
};
|
|
||||||
# portable sleeping falls back to native Sleep on Windows
|
|
||||||
eval {
|
|
||||||
no warnings "all";
|
|
||||||
require Win32;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use serverhelp qw(
|
use serverhelp qw(
|
||||||
|
|
@ -69,27 +59,6 @@ use globalconfig qw(
|
||||||
$dev_null
|
$dev_null
|
||||||
);
|
);
|
||||||
|
|
||||||
#######################################################################
|
|
||||||
# portable_sleep uses Time::HiRes::sleep if available and falls back
|
|
||||||
# to the classic approach of using select(undef, undef, undef, ...).
|
|
||||||
# even though that one is not portable due to being implemented using
|
|
||||||
# select on Windows: https://perldoc.perl.org/perlport.html#select
|
|
||||||
# Therefore it uses Win32::Sleep on Windows systems instead.
|
|
||||||
#
|
|
||||||
sub portable_sleep {
|
|
||||||
my ($seconds) = @_;
|
|
||||||
|
|
||||||
if($Time::HiRes::VERSION) {
|
|
||||||
Time::HiRes::sleep($seconds);
|
|
||||||
}
|
|
||||||
elsif(os_is_win()) {
|
|
||||||
Win32::Sleep($seconds*1000);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
select(undef, undef, undef, $seconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# pidfromfile returns the pid stored in the given pidfile. The value
|
# pidfromfile returns the pid stored in the given pidfile. The value
|
||||||
# of the returned pid will never be a negative value. It will be zero
|
# of the returned pid will never be a negative value. It will be zero
|
||||||
|
|
@ -238,7 +207,7 @@ sub pidwait {
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
portable_sleep(0.2);
|
Time::HiRes::sleep(0.2);
|
||||||
}
|
}
|
||||||
return $pid;
|
return $pid;
|
||||||
}
|
}
|
||||||
|
|
@ -346,7 +315,7 @@ sub killpid {
|
||||||
last if(not scalar(@signalled));
|
last if(not scalar(@signalled));
|
||||||
# give any zombies of us a chance to move on to the afterlife
|
# give any zombies of us a chance to move on to the afterlife
|
||||||
pidwait(0, &WNOHANG);
|
pidwait(0, &WNOHANG);
|
||||||
portable_sleep(0.05);
|
Time::HiRes::sleep(0.05);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ use warnings;
|
||||||
use 5.006;
|
use 5.006;
|
||||||
|
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
|
use Time::HiRes;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use base qw(Exporter);
|
use base qw(Exporter);
|
||||||
|
|
@ -84,9 +85,6 @@ use Storable qw(
|
||||||
use pathhelp qw(
|
use pathhelp qw(
|
||||||
exe_ext
|
exe_ext
|
||||||
);
|
);
|
||||||
use processhelp qw(
|
|
||||||
portable_sleep
|
|
||||||
);
|
|
||||||
use servers qw(
|
use servers qw(
|
||||||
checkcmd
|
checkcmd
|
||||||
initserverconfig
|
initserverconfig
|
||||||
|
|
@ -419,7 +417,7 @@ sub waitlockunlock {
|
||||||
my $lockretry = $serverlogslocktimeout * 20;
|
my $lockretry = $serverlogslocktimeout * 20;
|
||||||
my @locks;
|
my @locks;
|
||||||
while((@locks = logslocked()) && $lockretry--) {
|
while((@locks = logslocked()) && $lockretry--) {
|
||||||
portable_sleep(0.05);
|
Time::HiRes::sleep(0.05);
|
||||||
}
|
}
|
||||||
if(($lockretry < 0) &&
|
if(($lockretry < 0) &&
|
||||||
($serverlogslocktimeout >= $defserverlogslocktimeout)) {
|
($serverlogslocktimeout >= $defserverlogslocktimeout)) {
|
||||||
|
|
@ -1092,7 +1090,7 @@ sub singletest_clean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
portable_sleep($postcommanddelay) if($postcommanddelay);
|
Time::HiRes::sleep($postcommanddelay) if($postcommanddelay);
|
||||||
|
|
||||||
my @killtestservers = getpart("client", "killserver");
|
my @killtestservers = getpart("client", "killserver");
|
||||||
if(@killtestservers) {
|
if(@killtestservers) {
|
||||||
|
|
|
||||||
|
|
@ -92,9 +92,6 @@ use pathhelp qw(
|
||||||
exe_ext
|
exe_ext
|
||||||
sys_native_current_path
|
sys_native_current_path
|
||||||
);
|
);
|
||||||
use processhelp qw(
|
|
||||||
portable_sleep
|
|
||||||
);
|
|
||||||
|
|
||||||
use appveyor;
|
use appveyor;
|
||||||
use azure;
|
use azure;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ package serverhelp;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use Time::HiRes;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use base qw(Exporter);
|
use base qw(Exporter);
|
||||||
|
|
||||||
|
|
@ -52,13 +54,6 @@ BEGIN {
|
||||||
datasockf_pidfilename
|
datasockf_pidfilename
|
||||||
datasockf_logfilename
|
datasockf_logfilename
|
||||||
);
|
);
|
||||||
|
|
||||||
# sub second timestamping needs Time::HiRes
|
|
||||||
eval {
|
|
||||||
no warnings "all";
|
|
||||||
require Time::HiRes;
|
|
||||||
import Time::HiRes qw( gettimeofday );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use globalconfig;
|
use globalconfig;
|
||||||
|
|
@ -81,20 +76,10 @@ our $logfile; # server log file name, for logmsg
|
||||||
# logmsg is general message logging subroutine for our test servers.
|
# logmsg is general message logging subroutine for our test servers.
|
||||||
#
|
#
|
||||||
sub logmsg {
|
sub logmsg {
|
||||||
my $now;
|
my ($seconds, $usec) = Time::HiRes::gettimeofday();
|
||||||
# sub second timestamping needs Time::HiRes
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
|
||||||
if($Time::HiRes::VERSION) {
|
localtime($seconds);
|
||||||
my ($seconds, $usec) = gettimeofday();
|
my $now = sprintf("%02d:%02d:%02d.%06d ", $hour, $min, $sec, $usec);
|
||||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
|
|
||||||
localtime($seconds);
|
|
||||||
$now = sprintf("%02d:%02d:%02d.%06d ", $hour, $min, $sec, $usec);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
my $seconds = time();
|
|
||||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
|
|
||||||
localtime($seconds);
|
|
||||||
$now = sprintf("%02d:%02d:%02d ", $hour, $min, $sec);
|
|
||||||
}
|
|
||||||
# we see warnings on Windows run that $logfile is used uninitialized
|
# we see warnings on Windows run that $logfile is used uninitialized
|
||||||
# TODO: not found yet where this comes from
|
# TODO: not found yet where this comes from
|
||||||
$logfile = "serverhelp_uninitialized.log" if(!$logfile);
|
$logfile = "serverhelp_uninitialized.log" if(!$logfile);
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,7 @@ sub startnew {
|
||||||
logmsg "startnew: failed to write fake $pidfile with pid=$child\n";
|
logmsg "startnew: failed to write fake $pidfile with pid=$child\n";
|
||||||
}
|
}
|
||||||
# could/should do a while connect fails sleep a bit and loop
|
# could/should do a while connect fails sleep a bit and loop
|
||||||
portable_sleep($timeout);
|
Time::HiRes::sleep($timeout);
|
||||||
if(checkdied($child)) {
|
if(checkdied($child)) {
|
||||||
logmsg "startnew: child process has failed to start\n" if($verbose);
|
logmsg "startnew: child process has failed to start\n" if($verbose);
|
||||||
return (-1,-1);
|
return (-1,-1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue