On Wed Feb 04 00:01:55 2015, DBOOK wrote:
Show quoted text
I've managed to squash out the test into a smaller one, directly on the Loop ->watch_io method (rather than involving Notifiers).
Now added to LoopTests (so all loops are tested for it), and fixed in Select.pm
--
Paul Evans
=== modified file 'lib/IO/Async/Loop/Select.pm'
--- lib/IO/Async/Loop/Select.pm 2014-10-17 16:54:33 +0000
+++ lib/IO/Async/Loop/Select.pm 2015-02-14 19:06:11 +0000
@@ -1,7 +1,7 @@
# You may distribute under the terms of either the GNU General Public License
# or the Artistic License (the same terms as Perl itself)
#
-# (C) Paul Evans, 2007-2013 -- leonerd@leonerd.org.uk
+# (C) Paul Evans, 2007-2015 -- leonerd@leonerd.org.uk
package IO::Async::Loop::Select;
@@ -177,7 +177,7 @@
alarm( IO::Async::Loop->WATCHDOG_INTERVAL ) if WATCHDOG_ENABLE;
foreach my $fd ( keys %$iowatches ) {
- my $watch = $iowatches->{$fd};
+ my $watch = $iowatches->{$fd} or next;
my $fileno = $watch->[0]->fileno;
=== modified file 'lib/IO/Async/LoopTests.pm'
--- lib/IO/Async/LoopTests.pm 2014-10-17 16:54:33 +0000
+++ lib/IO/Async/LoopTests.pm 2015-02-14 19:06:11 +0000
@@ -1,7 +1,7 @@
# You may distribute under the terms of either the GNU General Public License
# or the Artistic License (the same terms as Perl itself)
#
-# (C) Paul Evans, 2009-2013 -- leonerd@leonerd.org.uk
+# (C) Paul Evans, 2009-2015 -- leonerd@leonerd.org.uk
package IO::Async::LoopTests;
@@ -158,7 +158,7 @@
=cut
-use constant count_tests_io => 17;
+use constant count_tests_io => 18;
sub run_tests_io
{
{
@@ -336,6 +336,28 @@
is( $callcount, 1, 'read/write_ready can cancel each other' );
}
+ # Check that cross-connected handlers can cancel each other
+ {
+ my ( $SA1, $SA2 ) = IO::Async::OS->socketpair or die "Cannot socketpair - $!";
+ my ( $SB1, $SB2 ) = IO::Async::OS->socketpair or die "Cannot socketpair - $!";
+ $_->blocking( 0 ) for $SA1, $SA2, $SB1, $SB2;
+
+ my @handles = ( $SA1, $SB1 );
+
+ my $callcount = 0;
+ $loop->watch_io(
+ handle => $_,
+ on_write_ready => sub {
+ $callcount++;
+ $loop->unwatch_io( handle => $_, on_write_ready => 1 ) for @handles;
+ },
+ ) for @handles;
+
+ $loop->loop_once( 0.1 );
+
+ is( $callcount, 1, 'write_ready on crosslinked handles can cancel each other' );
+ }
+
# Check that error conditions that aren't true read/write-ability are still
# invoked
{