Skip to content

Commit

Permalink
[perl #75156] fix the return value and bits for removing a closed fh
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed Nov 11, 2013
1 parent 3bfb061 commit ff4a442
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
27 changes: 18 additions & 9 deletions dist/IO/lib/IO/Select.pm
Expand Up @@ -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

Expand Down Expand Up @@ -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++;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/IO/t/io_sel.t
Expand Up @@ -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";
}

0 comments on commit ff4a442

Please sign in to comment.