summaryrefslogtreecommitdiff
path: root/dist/IO
diff options
context:
space:
mode:
authorFranz Fasching <perldev@drfasching.com>2011-01-27 08:46:59 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-01-27 14:52:43 -0800
commit2e6546ca5fa4881dcdcee01b529da819be282299 (patch)
tree93aade9a66abf6da20364daae0a6b1142048296e /dist/IO
parent5ccb3a28fc30a358c7870c0f979a11d432b97664 (diff)
downloadperl-2e6546ca5fa4881dcdcee01b529da819be282299.tar.gz
IO::Select: allow removal of IO::Handle objects without fileno
Diffstat (limited to 'dist/IO')
-rw-r--r--dist/IO/lib/IO/Select.pm10
1 files changed, 8 insertions, 2 deletions
diff --git a/dist/IO/lib/IO/Select.pm b/dist/IO/lib/IO/Select.pm
index fc05fe70e9..4020078488 100644
--- a/dist/IO/lib/IO/Select.pm
+++ b/dist/IO/lib/IO/Select.pm
@@ -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;
@@ -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;