This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make IO::Poll->poll call _poll even with an empty fd array
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Fri, 16 Oct 2015 16:23:40 +0000 (17:23 +0100)
committerTony Cook <tony@develop-help.com>
Mon, 19 Oct 2015 02:14:04 +0000 (13:14 +1100)
Now that _poll() properly handles an empty array, this fixes
[rt.cpan.org #25049].  The commit referenced in that ticket never made
it to CPAN nor blead.

dist/IO/lib/IO/Poll.pm
dist/IO/t/io_poll.t

index 47f1a13..a02dc3d 100644 (file)
@@ -13,7 +13,7 @@ use Exporter ();
 our(@ISA, @EXPORT_OK, @EXPORT, $VERSION);
 
 @ISA = qw(Exporter);
-$VERSION = "0.09";
+$VERSION = "0.10";
 
 @EXPORT = qw( POLLIN
              POLLOUT
@@ -83,7 +83,7 @@ sub poll {
        push(@poll,$fd => $mask);
     }
 
-    my $ret = @poll ? _poll(defined($timeout) ? $timeout * 1000 : -1,@poll) : 0;
+    my $ret = _poll(defined($timeout) ? $timeout * 1000 : -1,@poll);
 
     return $ret
        unless $ret > 0;
index 364d346..c58467c 100644 (file)
@@ -8,7 +8,7 @@ if ($^O eq 'mpeix') {
 select(STDERR); $| = 1;
 select(STDOUT); $| = 1;
 
-print "1..10\n";
+print "1..12\n";
 
 use IO::Handle;
 use IO::Poll qw(/POLL/);
@@ -81,3 +81,12 @@ close STDIN;
 print "not "
     if $poll->poll(0.1);
 print "ok 10\n";
+
+my $wait = IO::Poll->new;
+my $now = time;
+my $zero = $wait->poll(2);
+my $diff = time - $now;
+print "not " if !defined($zero) or $zero;
+print "ok 11\n";
+print "not " unless $diff >= 2;
+print "ok 12\n";