diff --git a/dist/IO/lib/IO/Select.pm b/dist/IO/lib/IO/Select.pm index 756a299c3487..994f8966ab61 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 bd61b6842bf9..34af03a3e851 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"; }