IO::Poll: Removing Handles
Matthew Sachs [Sun, 17 Feb 2002 04:49:46 +0000 (23:49 -0500)]
   Message-Id: <20020217094946.GA13130@allevil.dhcp.zevils.com>

p4raw-id: //depot/perl@14743

ext/IO/lib/IO/Poll.pm

index 70a3469..89b89d4 100644 (file)
@@ -13,7 +13,7 @@ use Exporter ();
 our(@ISA, @EXPORT_OK, @EXPORT, $VERSION);
 
 @ISA = qw(Exporter);
-$VERSION = "0.05";
+$VERSION = "0.06";
 
 @EXPORT = qw( POLLIN
              POLLOUT
@@ -53,9 +53,13 @@ sub mask {
          $self->[1]{$fd}      = 0;     # output mask
          $self->[2]{$io}      = $io;   # remember handle
        } else {
-           delete $self->[0]{$fd}{$io};
-         delete $self->[1]{$fd} unless %{$self->[0]{$fd}};
-         delete $self->[2]{$io};
+          delete $self->[0]{$fd}{$io};
+          unless(%{$self->[0]{$fd}}) {
+            # We no longer have any handles for this FD
+            delete $self->[1]{$fd};
+            delete $self->[0]{$fd};
+          }
+          delete $self->[2]{$io};
        }
     }