summaryrefslogtreecommitdiff
path: root/tests/ftp.pm
diff options
context:
space:
mode:
authornikita <tek.no.katze@gmail.com>2020-04-01 14:27:11 +0200
committernikita <tek.no.katze@gmail.com>2020-04-01 14:27:11 +0200
commit10e1f0a795a8d2375eeb30b01c71363fdbcc5895 (patch)
treeb6c084e5021b8d5c40b6aecd495798d187d2fcd5 /tests/ftp.pm
parent69758416170305e04324a85bfe74cd62673e298b (diff)
parentb81e0b07784dc4c1e8d0a86194b9d28776d071c0 (diff)
downloadgnurl-10e1f0a795a8d2375eeb30b01c71363fdbcc5895.tar.gz
gnurl-10e1f0a795a8d2375eeb30b01c71363fdbcc5895.tar.bz2
gnurl-10e1f0a795a8d2375eeb30b01c71363fdbcc5895.zip
Merge tag 'curl-7_69_1'
7.69.1
Diffstat (limited to 'tests/ftp.pm')
-rw-r--r--tests/ftp.pm38
1 files changed, 36 insertions, 2 deletions
diff --git a/tests/ftp.pm b/tests/ftp.pm
index f4a4acedd..5e92ce7f9 100644
--- a/tests/ftp.pm
+++ b/tests/ftp.pm
@@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -20,6 +20,19 @@
#
###########################################################################
+BEGIN {
+ # portable sleeping needs Time::HiRes
+ eval {
+ no warnings "all";
+ require Time::HiRes;
+ };
+ # portable sleeping falls back to native Sleep on Win32
+ eval {
+ no warnings "all";
+ require Win32;
+ }
+}
+
use strict;
use warnings;
@@ -30,6 +43,27 @@ use serverhelp qw(
);
#######################################################################
+# 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
+# On Windows it also just uses full-second sleep for waits >1 second.
+#
+sub portable_sleep {
+ my ($seconds) = @_;
+
+ if($Time::HiRes::VERSION) {
+ Time::HiRes::sleep($seconds);
+ }
+ elsif ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'msys') {
+ 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
# on any file related error or if a pid can not be extracted from the
@@ -216,7 +250,7 @@ sub killpid {
}
}
last if(not scalar(@signalled));
- select(undef, undef, undef, 0.05);
+ portable_sleep(0.05);
}
}