In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/03a8022922436d6126806f2021d599237739ff83?hp=1e777496fd51e7d05020c0f05a4f2e19f2a3148d>

- Log -----------------------------------------------------------------
commit 03a8022922436d6126806f2021d599237739ff83
Author: Dagfinn Ilmari Mannsåker <ilm...@ilmari.org>
Date:   Fri Oct 16 17:23:40 2015 +0100

    Make IO::Poll->poll call _poll even with an empty fd array
    
    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.

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

commit 908febd9653d134c36cf212757ff14729d2d70ee
Author: Dagfinn Ilmari Mannsåker <ilm...@ilmari.org>
Date:   Fri Oct 16 17:20:04 2015 +0100

    Fix assertion when calling IO::Poll::_poll() with an empty fd array
    
      perl: IO.xs:322: XS_IO__Poll__poll: Assertion
      `PL_valid_types_PVX[((svtype)((_svpvx)->sv_flags & 0xff)) & 0xf]'
      failed.
    
    This is because NEWSV(…, 0) returns undef, with a grabage pointer in
    the PV slot.  This doesn't seem to matter in practice, since nothing
    actually dereferences the pointer when nfds is zero, but to be safe we
    should pass in _some_ valid pointer, so just use the SV* itself;

M       dist/IO/IO.pm
M       dist/IO/IO.xs
-----------------------------------------------------------------------

Summary of changes:
 dist/IO/IO.pm          |  2 +-
 dist/IO/IO.xs          |  5 ++++-
 dist/IO/lib/IO/Poll.pm |  4 ++--
 dist/IO/t/io_poll.t    | 11 ++++++++++-
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/dist/IO/IO.pm b/dist/IO/IO.pm
index 2762958..de3e991 100644
--- a/dist/IO/IO.pm
+++ b/dist/IO/IO.pm
@@ -7,7 +7,7 @@ use Carp;
 use strict;
 use warnings;
 
-our $VERSION = "1.35";
+our $VERSION = "1.36";
 XSLoader::load 'IO', $VERSION;
 
 sub import {
diff --git a/dist/IO/IO.xs b/dist/IO/IO.xs
index 1f546b9..fe749a6 100644
--- a/dist/IO/IO.xs
+++ b/dist/IO/IO.xs
@@ -319,7 +319,10 @@ PPCODE:
 #ifdef HAS_POLL
     const int nfd = (items - 1) / 2;
     SV *tmpsv = NEWSV(999,nfd * sizeof(struct pollfd));
-    struct pollfd *fds = (struct pollfd *)SvPVX(tmpsv);
+    /* We should pass _some_ valid pointer even if nfd is zero, but it
+     * doesn't matter what it is, since we're telling it to not check any fds.
+     */
+    struct pollfd *fds = nfd ? (struct pollfd *)SvPVX(tmpsv) : (struct pollfd 
*)tmpsv;
     int i,j,ret;
     for(i=1, j=0  ; j < nfd ; j++) {
        fds[j].fd = SvIV(ST(i));
diff --git a/dist/IO/lib/IO/Poll.pm b/dist/IO/lib/IO/Poll.pm
index 47f1a13..a02dc3d 100644
--- a/dist/IO/lib/IO/Poll.pm
+++ b/dist/IO/lib/IO/Poll.pm
@@ -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;
diff --git a/dist/IO/t/io_poll.t b/dist/IO/t/io_poll.t
index 364d346..c58467c 100644
--- a/dist/IO/t/io_poll.t
+++ b/dist/IO/t/io_poll.t
@@ -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";

--
Perl5 Master Repository

Reply via email to