mirror of
https://github.com/curl/curl.git
synced 2026-06-24 06:35:38 +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
|
|
@ -27,11 +27,12 @@ package processhelp;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Time::HiRes;
|
||||
|
||||
BEGIN {
|
||||
use base qw(Exporter);
|
||||
|
||||
our @EXPORT = qw(
|
||||
portable_sleep
|
||||
pidfromfile
|
||||
pidexists
|
||||
pidwait
|
||||
|
|
@ -42,17 +43,6 @@ BEGIN {
|
|||
set_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(
|
||||
|
|
@ -69,27 +59,6 @@ use globalconfig qw(
|
|||
$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
|
||||
# of the returned pid will never be a negative value. It will be zero
|
||||
|
|
@ -238,7 +207,7 @@ sub pidwait {
|
|||
last;
|
||||
}
|
||||
}
|
||||
portable_sleep(0.2);
|
||||
Time::HiRes::sleep(0.2);
|
||||
}
|
||||
return $pid;
|
||||
}
|
||||
|
|
@ -346,7 +315,7 @@ sub killpid {
|
|||
last if(not scalar(@signalled));
|
||||
# give any zombies of us a chance to move on to the afterlife
|
||||
pidwait(0, &WNOHANG);
|
||||
portable_sleep(0.05);
|
||||
Time::HiRes::sleep(0.05);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue