r47713 - in /trunk/libio-async-perl: ./ debian/ lib/IO/ lib/IO/Async/ lib/IO/Async/Loop/ lib/IO/Async/Timer/ t/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Tue Nov 24 03:20:45 UTC 2009


Author: jawnsy-guest
Date: Tue Nov 24 03:20:40 2009
New Revision: 47713

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=47713
Log:
New upstream release

Modified:
    trunk/libio-async-perl/Changes
    trunk/libio-async-perl/META.yml
    trunk/libio-async-perl/debian/changelog
    trunk/libio-async-perl/lib/IO/Async.pm
    trunk/libio-async-perl/lib/IO/Async/ChildManager.pm
    trunk/libio-async-perl/lib/IO/Async/Connector.pm
    trunk/libio-async-perl/lib/IO/Async/DetachedCode.pm
    trunk/libio-async-perl/lib/IO/Async/Handle.pm
    trunk/libio-async-perl/lib/IO/Async/Listener.pm
    trunk/libio-async-perl/lib/IO/Async/Loop.pm
    trunk/libio-async-perl/lib/IO/Async/Loop/IO_Poll.pm
    trunk/libio-async-perl/lib/IO/Async/Loop/Poll.pm
    trunk/libio-async-perl/lib/IO/Async/Loop/Select.pm
    trunk/libio-async-perl/lib/IO/Async/LoopTests.pm
    trunk/libio-async-perl/lib/IO/Async/MergePoint.pm
    trunk/libio-async-perl/lib/IO/Async/Notifier.pm
    trunk/libio-async-perl/lib/IO/Async/Resolver.pm
    trunk/libio-async-perl/lib/IO/Async/Sequencer.pm
    trunk/libio-async-perl/lib/IO/Async/Signal.pm
    trunk/libio-async-perl/lib/IO/Async/Stream.pm
    trunk/libio-async-perl/lib/IO/Async/Test.pm
    trunk/libio-async-perl/lib/IO/Async/Timer.pm
    trunk/libio-async-perl/lib/IO/Async/Timer/Countdown.pm
    trunk/libio-async-perl/lib/IO/Async/Timer/Periodic.pm
    trunk/libio-async-perl/t/21stream.t
    trunk/libio-async-perl/t/24listener.t

Modified: trunk/libio-async-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/Changes?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/Changes (original)
+++ trunk/libio-async-perl/Changes Tue Nov 24 03:20:40 2009
@@ -1,4 +1,10 @@
 Revision history for IO-Async
+
+0.26    BUGFIXES:
+         * Connect to INADDR_LOOPBACK rather than INADDR_ANY during
+           t/24listener.t; hopefully fixes FAILs on OpenBSD
+         * Fix IO::Async::Stream during combined read/write-ready of a closed
+           stream
 
 0.25    CHANGES:
          * Accept 'stream'/'dgram'/'raw' as symbolic shortcuts for socket

Modified: trunk/libio-async-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/META.yml?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/META.yml (original)
+++ trunk/libio-async-perl/META.yml Tue Nov 24 03:20:40 2009
@@ -1,6 +1,6 @@
 ---
 name: IO-Async
-version: 0.25
+version: 0.26
 author:
   - 'Paul Evans <leonerd at leonerd.org.uk>'
 abstract: perform asynchronous filehandle IO and other operations
@@ -24,67 +24,67 @@
 provides:
   IO::Async:
     file: lib/IO/Async.pm
-    version: 0.25
+    version: 0.26
   IO::Async::ChildManager:
     file: lib/IO/Async/ChildManager.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Connector:
     file: lib/IO/Async/Connector.pm
-    version: 0.25
+    version: 0.26
   IO::Async::DetachedCode:
     file: lib/IO/Async/DetachedCode.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Handle:
     file: lib/IO/Async/Handle.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Listener:
     file: lib/IO/Async/Listener.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Loop:
     file: lib/IO/Async/Loop.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Loop::IO_Poll:
     file: lib/IO/Async/Loop/IO_Poll.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Loop::Poll:
     file: lib/IO/Async/Loop/Poll.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Loop::Select:
     file: lib/IO/Async/Loop/Select.pm
-    version: 0.25
+    version: 0.26
   IO::Async::LoopTests:
     file: lib/IO/Async/LoopTests.pm
-    version: 0.25
+    version: 0.26
   IO::Async::MergePoint:
     file: lib/IO/Async/MergePoint.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Notifier:
     file: lib/IO/Async/Notifier.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Resolver:
     file: lib/IO/Async/Resolver.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Sequencer:
     file: lib/IO/Async/Sequencer.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Signal:
     file: lib/IO/Async/Signal.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Stream:
     file: lib/IO/Async/Stream.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Test:
     file: lib/IO/Async/Test.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Timer:
     file: lib/IO/Async/Timer.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Timer::Countdown:
     file: lib/IO/Async/Timer/Countdown.pm
-    version: 0.25
+    version: 0.26
   IO::Async::Timer::Periodic:
     file: lib/IO/Async/Timer/Periodic.pm
-    version: 0.25
+    version: 0.26
 generated_by: Module::Build version 0.35
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html

Modified: trunk/libio-async-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/debian/changelog?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/debian/changelog (original)
+++ trunk/libio-async-perl/debian/changelog Tue Nov 24 03:20:40 2009
@@ -1,3 +1,9 @@
+libio-async-perl (0.26-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Jonathan Yu <jawnsy at cpan.org>  Mon, 23 Nov 2009 18:56:41 -0500
+
 libio-async-perl (0.25-1) unstable; urgency=low
 
   [ Jonathan Yu ]

Modified: trunk/libio-async-perl/lib/IO/Async.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async.pm Tue Nov 24 03:20:40 2009
@@ -12,7 +12,7 @@
 # It is provided simply to keep CPAN happy:
 #   cpan -i IO::Async
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 =head1 NAME
 

Modified: trunk/libio-async-perl/lib/IO/Async/ChildManager.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/ChildManager.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/ChildManager.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/ChildManager.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 # Not a notifier
 

Modified: trunk/libio-async-perl/lib/IO/Async/Connector.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Connector.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Connector.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Connector.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use POSIX qw( EINPROGRESS );
 use Socket qw( SOL_SOCKET SO_ERROR );

Modified: trunk/libio-async-perl/lib/IO/Async/DetachedCode.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/DetachedCode.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/DetachedCode.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/DetachedCode.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use IO::Async::Stream;
 

Modified: trunk/libio-async-perl/lib/IO/Async/Handle.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Handle.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Handle.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Handle.pm Tue Nov 24 03:20:40 2009
@@ -9,7 +9,7 @@
 use warnings;
 use base qw( IO::Async::Notifier );
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use Carp;
 use Scalar::Util qw( weaken );

Modified: trunk/libio-async-perl/lib/IO/Async/Listener.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Listener.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Listener.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Listener.pm Tue Nov 24 03:20:40 2009
@@ -9,7 +9,7 @@
 use warnings;
 use base qw( IO::Async::Handle );
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use IO::Async::Handle;
 

Modified: trunk/libio-async-perl/lib/IO/Async/Loop.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Loop.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Loop.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Loop.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 use constant NEED_API_VERSION => '0.24';
 
 use Carp;

Modified: trunk/libio-async-perl/lib/IO/Async/Loop/IO_Poll.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Loop/IO_Poll.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Loop/IO_Poll.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Loop/IO_Poll.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use base qw( IO::Async::Loop::Poll );
 

Modified: trunk/libio-async-perl/lib/IO/Async/Loop/Poll.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Loop/Poll.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Loop/Poll.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Loop/Poll.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 use constant API_VERSION => '0.24';
 
 use base qw( IO::Async::Loop );
@@ -141,30 +141,23 @@
    my $iowatches = $self->{iowatches};
    my $poll      = $self->{poll};
 
-   # Build a list of the callbacks to fire, then fire them afterwards.
-   # This avoids races and other bad effects if any of the callbacks happen
-   # to change any state.
-   my @ready;
+   my $count = 0;
 
    foreach my $fd ( keys %$iowatches ) {
-      my $watch = $iowatches->{$fd};
+      my $watch = $iowatches->{$fd} or next;
 
       my $events = $poll->events( $watch->[0] );
 
       # We have to test separately because kernel doesn't report POLLIN when
       # a pipe gets closed.
       if( $events & (POLLIN|POLLHUP) ) {
-         push @ready, $watch->[1] if defined $watch->[1];
+         $count++, $watch->[1]->() if defined $watch->[1];
       }
 
       if( $events & (POLLOUT|POLLHUP) ) {
-         push @ready, $watch->[2] if defined $watch->[2];
+         $count++, $watch->[2]->() if defined $watch->[2];
       }
    }
-
-   my $count = @ready;
-
-   $_->() foreach @ready;
 
    # Since we have no way to know if the timeout occured, we'll have to
    # attempt to fire any waiting timeout events anyway

Modified: trunk/libio-async-perl/lib/IO/Async/Loop/Select.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Loop/Select.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Loop/Select.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Loop/Select.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 use constant API_VERSION => '0.24';
 
 use base qw( IO::Async::Loop );
@@ -157,10 +157,7 @@
 
    my $iowatches = $self->{iowatches};
 
-   # Build a list of the callbacks to fire, then fire them afterwards.
-   # This avoids races and other bad effects if any of the callbacks happen
-   # to change any state.
-   my @ready;
+   my $count = 0;
 
    foreach my $fd ( keys %$iowatches ) {
       my $watch = $iowatches->{$fd};
@@ -168,15 +165,13 @@
       my $fileno = $watch->[0]->fileno;
 
       if( vec( $readvec, $fileno, 1 ) ) {
-         push @ready, $watch->[1] if defined $watch->[1];
+         $count++, $watch->[1]->() if defined $watch->[1];
       }
 
       if( vec( $writevec, $fileno, 1 ) ) {
-         push @ready, $watch->[2] if defined $watch->[2];
+         $count++, $watch->[2]->() if defined $watch->[2];
       }
    }
-
-   $_->() foreach @ready;
 
    # Since we have no way to know if the timeout occured, we'll have to
    # attempt to fire any waiting timeout events anyway

Modified: trunk/libio-async-perl/lib/IO/Async/LoopTests.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/LoopTests.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/LoopTests.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/LoopTests.pm Tue Nov 24 03:20:40 2009
@@ -22,7 +22,7 @@
 use POSIX qw( SIGTERM WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG );
 use Time::HiRes qw( time );
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 # Abstract Units of Time
 use constant AUT => $ENV{TEST_QUICK_TIMERS} ? 0.1 : 1;
@@ -144,7 +144,7 @@
 
 =cut
 
-use constant count_tests_io => 10;
+use constant count_tests_io => 11;
 sub run_tests_io
 {
    my ( $S1, $S2 ) = $loop->socketpair() or die "Cannot create socket pair - $!";
@@ -237,6 +237,29 @@
       handle => $P1,
       on_read_ready => 1,
    );
+
+   # Check that combined read/write handlers can cancel each other
+
+   ( $S1, $S2 ) = $loop->socketpair() or die "Cannot socketpair - $!";
+
+   my $callcount = 0;
+   $loop->watch_io(
+      handle => $S1,
+      on_read_ready => sub {
+         $callcount++;
+         $loop->unwatch_io( handle => $S1, on_read_ready => 1, on_write_ready => 1 );
+      },
+      on_write_ready => sub {
+         $callcount++;
+         $loop->unwatch_io( handle => $S1, on_read_ready => 1, on_write_ready => 1 );
+      },
+   );
+
+   $S2->close;
+
+   $loop->loop_once( 0.1 );
+
+   is( $callcount, 1, 'read/write_ready can cancel each other' );
 }
 
 =head2 timer

Modified: trunk/libio-async-perl/lib/IO/Async/MergePoint.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/MergePoint.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/MergePoint.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/MergePoint.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use Carp;
 

Modified: trunk/libio-async-perl/lib/IO/Async/Notifier.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Notifier.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Notifier.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Notifier.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use Carp;
 use Scalar::Util qw( weaken );

Modified: trunk/libio-async-perl/lib/IO/Async/Resolver.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Resolver.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Resolver.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Resolver.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use Socket::GetAddrInfo qw( :Socket6api getaddrinfo getnameinfo );
 use Socket qw( SOCK_STREAM SOCK_DGRAM SOCK_RAW );

Modified: trunk/libio-async-perl/lib/IO/Async/Sequencer.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Sequencer.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Sequencer.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Sequencer.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use base qw( IO::Async::Stream );
 

Modified: trunk/libio-async-perl/lib/IO/Async/Signal.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Signal.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Signal.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Signal.pm Tue Nov 24 03:20:40 2009
@@ -9,7 +9,7 @@
 use warnings;
 use base qw( IO::Async::Notifier );
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use Carp;
 use Scalar::Util qw( weaken );

Modified: trunk/libio-async-perl/lib/IO/Async/Stream.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Stream.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Stream.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Stream.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use base qw( IO::Async::Handle );
 

Modified: trunk/libio-async-perl/lib/IO/Async/Test.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Test.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Test.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Test.pm Tue Nov 24 03:20:40 2009
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use Exporter;
 our @ISA = qw( Exporter );

Modified: trunk/libio-async-perl/lib/IO/Async/Timer.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Timer.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Timer.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Timer.pm Tue Nov 24 03:20:40 2009
@@ -9,7 +9,7 @@
 use warnings;
 use base qw( IO::Async::Notifier );
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use Carp;
 

Modified: trunk/libio-async-perl/lib/IO/Async/Timer/Countdown.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Timer/Countdown.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Timer/Countdown.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Timer/Countdown.pm Tue Nov 24 03:20:40 2009
@@ -9,7 +9,7 @@
 use warnings;
 use base qw( IO::Async::Timer );
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use Carp;
 use Scalar::Util qw( weaken );
@@ -178,6 +178,52 @@
 
 __END__
 
+=head1 EXAMPLES
+
+=head2 Watchdog Timer
+
+Because the C<reset> method restarts a running countdown timer back to its
+full period, it can be used to implement a watchdog timer. This is a timer
+which will not expire provided the method is called at least as often as it
+is configured. If the method fails to be called, the timer will eventually
+expire and run its callback.
+
+For example, to expire an accepted connection after 30 seconds of inactivity:
+
+ ...
+
+ on_accept => sub {
+    my ( $newclient ) = @_;
+
+    my $stream;
+
+    my $watchdog = IO::Async::Timer::Countdown->new(
+       delay => 30,
+
+       on_expire => sub { $stream->close },
+    );
+
+    my $stream = IO::Async::Stream->new(
+       handle => $newclient,
+
+       on_read => sub {
+          my ( $self, $buffref, $closed ) = @_;
+          $stream->reset;
+
+          ...
+       },
+
+       on_closed => sub {
+          $watchdog->stop;
+       },
+    ) );
+
+    $watchdog->start;
+
+    $loop->add( $stream );
+    $loop->add( $watchdog );
+ }
+
 =head1 AUTHOR
 
 Paul Evans <leonerd at leonerd.org.uk>

Modified: trunk/libio-async-perl/lib/IO/Async/Timer/Periodic.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/lib/IO/Async/Timer/Periodic.pm?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/lib/IO/Async/Timer/Periodic.pm (original)
+++ trunk/libio-async-perl/lib/IO/Async/Timer/Periodic.pm Tue Nov 24 03:20:40 2009
@@ -9,7 +9,7 @@
 use warnings;
 use base qw( IO::Async::Timer );
 
-our $VERSION = '0.25';
+our $VERSION = '0.26';
 
 use Carp;
 use Scalar::Util qw( weaken );

Modified: trunk/libio-async-perl/t/21stream.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/t/21stream.t?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/t/21stream.t (original)
+++ trunk/libio-async-perl/t/21stream.t Tue Nov 24 03:20:40 2009
@@ -2,7 +2,7 @@
 
 use strict;
 
-use Test::More tests => 69;
+use Test::More tests => 71;
 use Test::Exception;
 use Test::Refcount;
 
@@ -418,6 +418,27 @@
 
 undef $stream;
 
+{
+   my ( $S1, $S2 ) = $loop->socketpair() or die "Cannot socketpair - $!";
+
+   my $stream = IO::Async::Stream->new(
+      handle => $S1,
+      on_read => sub { },
+   );
+
+   $stream->write( "hello" );
+
+   $loop->add( $stream );
+
+   is_refcount( $stream, 2, '$stream has two references' );
+   undef $stream; # Only ref is now in the Loop
+
+   $S2->close;
+
+   # $S1 should now be both read- and write-ready.
+   lives_ok sub { $loop->loop_once }, 'read+write-ready closed Stream doesn\'t die';
+}
+
 # Socket errors
 
 my ( $ES1, $ES2 ) = $loop->socketpair() or die "Cannot socketpair - $!";

Modified: trunk/libio-async-perl/t/24listener.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libio-async-perl/t/24listener.t?rev=47713&op=diff
==============================================================================
--- trunk/libio-async-perl/t/24listener.t (original)
+++ trunk/libio-async-perl/t/24listener.t Tue Nov 24 03:20:40 2009
@@ -4,7 +4,7 @@
 
 use IO::Async::Test;
 
-use Test::More tests => 22;
+use Test::More tests => 25;
 use Test::Refcount;
 
 use IO::Async::Loop::Poll;
@@ -119,13 +119,21 @@
 
 ok( $listener->is_listening, '$listener is_listening' );
 
+my $sockname = $listener->sockname;
+ok( defined $sockname, 'defined $sockname' );
+
+my ( $port, $sinaddr ) = unpack_sockaddr_in( $sockname );
+
+ok( $port > 0, 'socket listens on some defined port number' );
+is( $sinaddr, INADDR_ANY, 'socket listens on INADDR_ANY' );
+
 is( $listen_self, $listener, '$listen_self is $listener' );
 undef $listen_self; # for refcount
 
 $clientsock = IO::Socket::INET->new( Type => SOCK_STREAM )
    or die "Cannot socket() - $!";
 
-$clientsock->connect( $listener->sockname ) or die "Cannot connect() - $!";
+$clientsock->connect( pack_sockaddr_in( $port, INADDR_LOOPBACK ) ) or die "Cannot connect() - $!";
 
 ok( defined $clientsock->peername, '$clientsock is connected' );
 




More information about the Pkg-perl-cvs-commits mailing list