diff options
author | Tony Cook <tony@develop-help.com> | 2013-09-18 15:55:12 +1000 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2013-11-11 11:48:03 +1100 |
commit | ff4a442c79158c7df99be693a8f8559a09cf6df7 (patch) | |
tree | 1eca30fc2f6e5b3da7e8cb6efaf6aa2562d1cb9c /dist | |
parent | 3bfb0615ce07345b2bdefdd1acbd343f4dfa21d7 (diff) | |
download | perl-ff4a442c79158c7df99be693a8f8559a09cf6df7.tar.gz |
[perl #75156] fix the return value and bits for removing a closed fh
Diffstat (limited to 'dist')
-rw-r--r-- | dist/IO/lib/IO/Select.pm | 27 | ||||
-rw-r--r-- | dist/IO/t/io_sel.t | 4 |
2 files changed, 20 insertions, 11 deletions
diff --git a/dist/IO/lib/IO/Select.pm b/dist/IO/lib/IO/Select.pm index 756a299c34..994f8966ab 100644 --- a/dist/IO/lib/IO/Select.pm +++ b/dist/IO/lib/IO/Select.pm @@ -11,7 +11,7 @@ use warnings::register; use vars qw($VERSION @ISA); require Exporter; -$VERSION = "1.21"; +$VERSION = "1.22"; @ISA = qw(Exporter); # This is only so we can do version checking @@ -86,15 +86,24 @@ sub _update $vec->[$i] = $f; } else { # remove if ( ! defined $fn ) { # remove if fileno undef'd - defined($_) && $_ == $f and do { $vec->[FD_COUNT]--; $_ = undef; } - for @{$vec}[FIRST_FD .. $#$vec]; - next; + $fn = 0; + for my $fe (@{$vec}[FIRST_FD .. $#$vec]) { + if (defined($fe) && $fe == $f) { + $vec->[FD_COUNT]--; + $fe = undef; + vec($bits, $fn, 1) = 0; + last; + } + ++$fn; + } + } + else { + my $i = $fn + FIRST_FD; + next unless defined $vec->[$i]; + $vec->[FD_COUNT]--; + vec($bits, $fn, 1) = 0; + $vec->[$i] = undef; } - my $i = $fn + FIRST_FD; - next unless defined $vec->[$i]; - $vec->[FD_COUNT]--; - vec($bits, $fn, 1) = 0; - $vec->[$i] = undef; } $count++; } diff --git a/dist/IO/t/io_sel.t b/dist/IO/t/io_sel.t index bd61b6842b..34af03a3e8 100644 --- a/dist/IO/t/io_sel.t +++ b/dist/IO/t/io_sel.t @@ -143,9 +143,9 @@ print "ok 23\n" ; print "ok 24 - added socket\n"; close $fh; print "not " unless $sel->remove($fh) == 1; - print "ok 25 - removed closed socket # TODO code doesn't update count\n"; + print "ok 25 - removed closed socket\n"; print "not " unless $sel->count == 1; print "ok 26 - count() updated\n"; print "not " unless $sel->bits ne $oldbits; - print "ok 27 - bits() updated # TODO code doesn't update bits\n"; + print "ok 27 - bits() updated\n"; } |