This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #75156] tests for deleting a closed handle from IO::Select
authorTony Cook <tony@develop-help.com>
Wed, 18 Sep 2013 05:20:19 +0000 (15:20 +1000)
committerTony Cook <tony@develop-help.com>
Mon, 11 Nov 2013 00:48:03 +0000 (11:48 +1100)
dist/IO/t/io_sel.t

index eb4bb90..bd61b68 100644 (file)
@@ -3,7 +3,7 @@
 select(STDERR); $| = 1;
 select(STDOUT); $| = 1;
 
-print "1..23\n";
+print "1..27\n";
 
 use IO::Select 1.09;
 
@@ -129,3 +129,23 @@ IO::Select::has_error();
 print "not " unless $w == 1 ;
 $w = 0 ;
 print "ok 23\n" ;
+
+{
+    # perl #75156 - test we can delete a closed handle
+    require IO::Socket::INET;
+    my $fh = IO::Socket::INET->new(
+      Listen => 5,
+    );
+    my $sel = IO::Select->new(\*STDIN);
+    $sel->add($fh);
+    my $oldbits = $sel->bits;
+    print "not " unless $sel->count == 2;
+    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 "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";
+}