Subject: | IO::Poll->poll() with no handles always returns immediately |
Using IO::Poll version 0.07, I notice that if I have $poll as an
IO::Poll object with not yet any file handles in it,
$poll->poll( 10 );
returns 0 immediately, rather than doing what a C programmer would
expect; namely, sleeping for upto 10 seconds anyway.
I notice this comes from the following source line (IO/Poll.pm line 86):
my $ret = @poll ? _poll(defined($timeout) ? $timeout * 1000 :
-1,@poll) : 0;
Could it simply be changed to always call _poll() even if the @poll
array is empty? Or does some underlying code rely on there being
something in there?
Failing that, would it be possible to deteriorate it to a sleep or
select call instead? One of the following perhaps:
my $ret = @poll ? _poll(...)
: sleep( $timeout );
or
my $ret = @poll ? _poll(...)
: select(undef,undef,undef, $timeout * 1000 )
noting that the former case using sleep() does not properly handle
timeouts of greater resolution than one second, unless the Time::HiRes
module is used, but perhaps IO::Poll shouldn't depend on that.
--
Paul Evans