Skip Menu |

This queue is for tickets about the Time-HiRes CPAN distribution.

Report information
The Basics
Id: 35899
Status: resolved
Priority: 0/
Queue: Time-HiRes

People
Owner: Nobody in particular
Requestors: KARASIK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.9715
Fixed in: (no value)



The following code fails when compiled with defined(HAS_SETITIMER) && defined(ITIMER_REAL): use strict; use Time::HiRes qw(alarm); my $alrm; $SIG{ALRM} = sub { $alrm++}; alarm(0.1); sleep(1); print $alrm ? "ok\n" : "fail\n"; The attached patch fixes the problem
Subject: perl-time-hires.diff
--- HiRes.xs.0 2008-05-10 20:02:23.000000000 +0200 +++ HiRes.xs 2008-05-11 18:44:53.000000000 +0200 @@ -925,7 +925,6 @@ CODE: if (useconds < 0 || uinterval < 0) croak("Time::HiRes::ualarm(%d, %d): negative time not invented yet", useconds, uinterval); - if (useconds >= IV_1E6 || uinterval >= IV_1E6) #if defined(HAS_SETITIMER) && defined(ITIMER_REAL) { struct itimerval itv; @@ -936,10 +935,10 @@ } } #else + if (useconds >= IV_1E6 || uinterval >= IV_1E6) croak("Time::HiRes::ualarm(%d, %d): useconds or uinterval equal to or more than %"IVdf, useconds, uinterval, IV_1E6); + RETVAL = ualarm(useconds, uinterval); #endif - else - RETVAL = ualarm(useconds, uinterval); OUTPUT: RETVAL @@ -954,7 +953,6 @@ { IV useconds = IV_1E6 * seconds; IV uinterval = IV_1E6 * interval; - if (seconds >= IV_1E6 || interval >= IV_1E6) #if defined(HAS_SETITIMER) && defined(ITIMER_REAL) { struct itimerval itv; @@ -965,8 +963,9 @@ } } #else - RETVAL = (NV)ualarm((IV)(seconds * IV_1E6), - (IV)(interval * IV_1E6)) / NV_1E6; + if (useconds >= IV_1E6 || uinterval >= IV_1E6) + croak("Time::HiRes::alarm(%d, %d): seconds or interval equal to or more than 1.0 ", useconds, uinterval, IV_1E6); + RETVAL = (NV)ualarm( useconds, uinterval) / NV_1E6; #endif }
Subject: Re: [rt.cpan.org #35899]
Date: Sun, 8 Jun 2008 19:02:58 +0100
To: KARASIK via RT <bug-Time-HiRes [...] rt.cpan.org>
From: Zefram <zefram [...] fysh.org>
KARASIK via RT wrote: Show quoted text
>The following code fails when compiled with defined(HAS_SETITIMER) && >defined(ITIMER_REAL):
The logic in alarm() is patently faulty, but I'm not convinced about your change to ualarm(), or the behaviour of alarm(1.2) on systems without setitimer(). I'll fix it in the next release, one way or another. -zefram
From: KARASIK [...] cpan.org
On Sun Jun 08 14:03:24 2008, zefram@fysh.org wrote: Show quoted text
> The logic in alarm() is patently faulty, but I'm not convinced about > your change to ualarm(), or the behaviour of alarm(1.2) on systems > without setitimer(). I'll fix it in the next release, one way or another.
I don't think I see any flaws in the patch, but that's of course subjective. I won't care though whether it will be my patch or anything else, as long as alarm(0.1) works on my system. /dk
Please try 1.9716 or later.