Skip to content

Commit

Permalink
IO::Select: allow removal of IO::Handle objects without fileno
Browse files Browse the repository at this point in the history
  • Loading branch information
Franz Fasching authored and Father Chrysostomos committed Jan 27, 2011
1 parent 5ccb3a2 commit 2e6546c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dist/IO/lib/IO/Select.pm
Expand Up @@ -74,9 +74,9 @@ sub _update
foreach $f (@_)
{
my $fn = $vec->_fileno($f);
next unless defined $fn;
my $i = $fn + FIRST_FD;
if ($add) {
next unless defined $fn;
my $i = $fn + FIRST_FD;
if (defined $vec->[$i]) {
$vec->[$i] = $f; # if array rest might be different, so we update
next;
Expand All @@ -85,6 +85,12 @@ sub _update
vec($bits, $fn, 1) = 1;
$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;
}
my $i = $fn + FIRST_FD;
next unless defined $vec->[$i];
$vec->[FD_COUNT]--;
vec($bits, $fn, 1) = 0;
Expand Down

0 comments on commit 2e6546c

Please sign in to comment.