Subject: | wrong calculation in clearalarm |
Hi,
the re-calculation of $ACTIVE_ALARM is wrong in the beginning of the
function for negative $index given:
IS
splice @ALARM_QUEUE, $index, $length;
if(($index < 0 ? $#ALARM_QUEUE+$index : $index) == $ACTIVE_ALARM) {
$ACTIVE_ALARM = -1;
CORE::alarm(0);
}
HAS TO BE
splice @ALARM_QUEUE, $index, $length;
if(($index < 0 ? $#ALARM_QUEUE + 2 + $index : $index) == $ACTIVE_ALARM) {
$ACTIVE_ALARM = -1;
CORE::alarm(0);
}
Otherwise, this example doesn't work:
-----------------------------------------------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use Alarm::Concurrent qw( :OVERLOAD :ALL );
setalarm (9, sub {die "main alarm (#9 sec) expired\n";});
printf("main alarm (#9 sec) set\n");
setalarm (3, sub {die "main alarm (#3 sec) expired\n";});
printf("main alarm (#3 sec) set\n");
clearalarm(-1);
clearalarm (-1);
exit (0);
-----------------------------------------------------------------------------------------------------------
result is:
frank@frank-desktop:~/workspace/Perl/alarm$ ./test.pl
main alarm (#9 sec) set
main alarm (#3 sec) set
Use of uninitialized value in addition (+) at
/usr/local/share/perl/5.8.8/Alarm/Concurrent.pm line 249.
Use of uninitialized value in addition (+) at
/usr/local/share/perl/5.8.8/Alarm/Concurrent.pm line 245.
Use of uninitialized value in addition (+) at
/usr/local/share/perl/5.8.8/Alarm/Concurrent.pm line 245.
Use of uninitialized value in addition (+) at
/usr/local/share/perl/5.8.8/Alarm/Concurrent.pm line 249.
Alarm clock!
Pls. check and correct - if i am right.
best rgds
Frank