summaryrefslogtreecommitdiff
path: root/ext/Time
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2002-01-04 17:28:46 +0000
committerAbhijit Menon-Sen <ams@wiw.org>2002-01-04 17:40:31 +0000
commitcfaba70a429eb18ae13e2af4a687abaa42cbeb24 (patch)
tree35d500b390a7c3d1588d47a3d1af63e50fe44c8d /ext/Time
parent66c981cfbf8973edae5c249baadc211ae6d6032f (diff)
downloadperl-cfaba70a429eb18ae13e2af4a687abaa42cbeb24.tar.gz
(retracted by #14057)
Subject: [PATCH] Time/HiRes/HiRes.t Message-Id: <20020104172845.D1013@Bagpuss.unfortu.net> p4raw-id: //depot/perl@14057
Diffstat (limited to 'ext/Time')
-rw-r--r--ext/Time/HiRes/HiRes.t16
1 files changed, 13 insertions, 3 deletions
diff --git a/ext/Time/HiRes/HiRes.t b/ext/Time/HiRes/HiRes.t
index e246d82f62..c09eaa7453 100644
--- a/ext/Time/HiRes/HiRes.t
+++ b/ext/Time/HiRes/HiRes.t
@@ -128,14 +128,24 @@ else {
my $tick = 0;
local $SIG{ALRM} = sub { $tick++ };
- my $one = time; $tick = 0; ualarm(10_000); sleep until $tick;
- my $two = time; $tick = 0; ualarm(10_000); sleep until $tick;
+ # This was previously written sleep 3 until $tick;
+ # But there is a small race condition here: the alarm may go off
+ # until ($tick) { Here!; sleep }
+ # In which case the sleep is forever.
+ # sleeping for 3 seconds will cause the test to fail but it's better than
+ # infinite hang. [Until someone produces a platform where sleep interferes
+ # with ualarm, in which case a more sophisticated self destruct will need
+ # to be written (eg fork, child sleeps for a long time, child kills parent
+ # if parent doesn't finish first (killing child))]
+
+ my $one = time; $tick = 0; ualarm(10_000); sleep 3 until $tick;
+ my $two = time; $tick = 0; ualarm(10_000); sleep 3 until $tick;
my $three = time;
ok 12, $one == $two || $two == $three, "slept too long, $one $two $three";
$tick = 0;
ualarm(10_000, 10_000);
- sleep until $tick >= 3;
+ sleep 3 until $tick >= 3;
ok 13, 1;
ualarm(0);
}