r66754 - in /branches/upstream/libanyevent-perl/current: ./ lib/ lib/AnyEvent/ lib/AnyEvent/Impl/ t/ t/handle/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Sat Jan 1 02:28:41 UTC 2011


Author: jawnsy-guest
Date: Sat Jan  1 02:28:34 2011
New Revision: 66754

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=66754
Log:
[svn-upgrade] new version libanyevent-perl (5.300)

Added:
    branches/upstream/libanyevent-perl/current/lib/AnyEvent/Impl/Cocoa.pm
Modified:
    branches/upstream/libanyevent-perl/current/Changes
    branches/upstream/libanyevent-perl/current/MANIFEST
    branches/upstream/libanyevent-perl/current/META.yml
    branches/upstream/libanyevent-perl/current/Makefile.PL
    branches/upstream/libanyevent-perl/current/README
    branches/upstream/libanyevent-perl/current/lib/AnyEvent.pm
    branches/upstream/libanyevent-perl/current/lib/AnyEvent/FAQ.pod
    branches/upstream/libanyevent-perl/current/lib/AnyEvent/Handle.pm
    branches/upstream/libanyevent-perl/current/lib/AnyEvent/Impl/IOAsync.pm
    branches/upstream/libanyevent-perl/current/lib/AnyEvent/Util.pm
    branches/upstream/libanyevent-perl/current/t/01_basic.t
    branches/upstream/libanyevent-perl/current/t/02_signals.t
    branches/upstream/libanyevent-perl/current/t/03_child.t
    branches/upstream/libanyevent-perl/current/t/04_condvar.t
    branches/upstream/libanyevent-perl/current/t/05_dns.t
    branches/upstream/libanyevent-perl/current/t/07_io.t
    branches/upstream/libanyevent-perl/current/t/08_idna.t
    branches/upstream/libanyevent-perl/current/t/handle/01_readline.t
    branches/upstream/libanyevent-perl/current/t/handle/02_write.t
    branches/upstream/libanyevent-perl/current/t/handle/03_http_req.t
    branches/upstream/libanyevent-perl/current/t/handle/04_listen.t

Modified: branches/upstream/libanyevent-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/Changes?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/Changes (original)
+++ branches/upstream/libanyevent-perl/current/Changes Sat Jan  1 02:28:34 2011
@@ -4,6 +4,19 @@
 TODO: catch AE::xxx for anyevent strict and anyevent debug
 TODO: anyevent::trace? or debug tracing all watchers?
 TODO: anyevent strict checking for $_ changes?
+
+5.3    Fri Dec 31 05:48:13 CET 2010
+	- major IOAsync patch by Paul Evans - 0.33 is required, as the major
+          issues with IO::Async have been solved in that version, including
+          the availabilty of a default loop!
+	- implement new wbuf_max parameter for AnyEvent::Handle.
+        - added Cocoa::EventLoop backend by Daisuke Murase.
+        - the default testsuite now honors PERL_ANYEVENT_MODEL (Paul Evans).
+        - clarify handle on_prepare documentation.
+	- set CLOEXEC flag on parent-side fd's in AnyEvent::Util::run_cmd,
+          to avoid leaking them to any child processes.
+        - try to force files into the arch-dependend lib directory, for the
+          half-"turly obsessive compulsive person"(s) that depend on it.
 
 5.29   Sun Dec  5 10:49:21 CET 2010
         - convert EV backend to EV 4.00 API (so better upgrade EV too).

Modified: branches/upstream/libanyevent-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/MANIFEST?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/MANIFEST (original)
+++ branches/upstream/libanyevent-perl/current/MANIFEST Sat Jan  1 02:28:34 2011
@@ -28,6 +28,7 @@
 lib/AnyEvent/Impl/EventLib.pm
 lib/AnyEvent/Impl/IOAsync.pm
 lib/AnyEvent/Impl/Irssi.pm
+lib/AnyEvent/Impl/Cocoa.pm
 
 t/00_load.t
 t/01_basic.t

Modified: branches/upstream/libanyevent-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/META.yml?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/META.yml (original)
+++ branches/upstream/libanyevent-perl/current/META.yml Sat Jan  1 02:28:34 2011
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               AnyEvent
-version:            5.29
+version:            5.3
 abstract:           ~
 author:  []
 license:            unknown

Modified: branches/upstream/libanyevent-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/Makefile.PL?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/Makefile.PL (original)
+++ branches/upstream/libanyevent-perl/current/Makefile.PL Sat Jan  1 02:28:34 2011
@@ -44,5 +44,32 @@
            "Async::Interrupt" => 1.0,
         }
     },
+    PM           => {
+        'lib/AE.pm'                      => '$(INST_LIBDIR)/AE.pm',
+        'lib/AnyEvent.pm'                => '$(INST_LIBDIR)/AnyEvent.pm',
+        'lib/AnyEvent/DNS.pm'            => '$(INST_LIBDIR)/AnyEvent/DNS.pm',
+        'lib/AnyEvent/Debug.pm'          => '$(INST_LIBDIR)/AnyEvent/Debug.pm',
+        'lib/AnyEvent/FAQ.pod'           => '$(INST_LIBDIR)/AnyEvent/FAQ.pod',
+        'lib/AnyEvent/Handle.pm'         => '$(INST_LIBDIR)/AnyEvent/Handle.pm',
+        'lib/AnyEvent/Impl/Cocoa.pm'     => '$(INST_LIBDIR)/AnyEvent/Impl/Cocoa.pm',
+        'lib/AnyEvent/Impl/EV.pm'        => '$(INST_LIBDIR)/AnyEvent/Impl/EV.pm',
+        'lib/AnyEvent/Impl/Event.pm'     => '$(INST_LIBDIR)/AnyEvent/Impl/Event.pm',
+        'lib/AnyEvent/Impl/EventLib.pm'  => '$(INST_LIBDIR)/AnyEvent/Impl/EventLib.pm',
+        'lib/AnyEvent/Impl/Glib.pm'      => '$(INST_LIBDIR)/AnyEvent/Impl/Glib.pm',
+        'lib/AnyEvent/Impl/IOAsync.pm'   => '$(INST_LIBDIR)/AnyEvent/Impl/IOAsync.pm',
+        'lib/AnyEvent/Impl/Irssi.pm'     => '$(INST_LIBDIR)/AnyEvent/Impl/Irssi.pm',
+        'lib/AnyEvent/Impl/POE.pm'       => '$(INST_LIBDIR)/AnyEvent/Impl/POE.pm',
+        'lib/AnyEvent/Impl/Perl.pm'      => '$(INST_LIBDIR)/AnyEvent/Impl/Perl.pm',
+        'lib/AnyEvent/Impl/Qt.pm'        => '$(INST_LIBDIR)/AnyEvent/Impl/Qt.pm',
+        'lib/AnyEvent/Impl/Tk.pm'        => '$(INST_LIBDIR)/AnyEvent/Impl/Tk.pm',
+        'lib/AnyEvent/Intro.pod'         => '$(INST_LIBDIR)/AnyEvent/Intro.pod',
+        'lib/AnyEvent/Socket.pm'         => '$(INST_LIBDIR)/AnyEvent/Socket.pm',
+        'lib/AnyEvent/Strict.pm'         => '$(INST_LIBDIR)/AnyEvent/Strict.pm',
+        'lib/AnyEvent/TLS.pm'            => '$(INST_LIBDIR)/AnyEvent/TLS.pm',
+        'lib/AnyEvent/Util.pm'           => '$(INST_LIBDIR)/AnyEvent/Util.pm',
+        'lib/AnyEvent/Util/idna.pl'      => '$(INST_LIBDIR)/AnyEvent/Util/idna.pl',
+        'lib/AnyEvent/Util/uts46data.pl' => '$(INST_LIBDIR)/AnyEvent/Util/uts46data.pl',
+        'lib/AnyEvent/constants.pl'      => '$(INST_ARCHLIBDIR)/AnyEvent/constants.pl',
+    },
 );
 

Modified: branches/upstream/libanyevent-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/README?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/README (original)
+++ branches/upstream/libanyevent-perl/current/README Sat Jan  1 02:28:34 2011
@@ -82,11 +82,11 @@
 
     AnyEvent is different: AnyEvent + POE works fine. AnyEvent + Glib works
     fine. AnyEvent + Tk works fine etc. etc. but none of these work together
-    with the rest: POE + IO::Async? No go. Tk + Event? No go. Again: if your
-    module uses one of those, every user of your module has to use it, too.
-    But if your module uses AnyEvent, it works transparently with all event
-    models it supports (including stuff like IO::Async, as long as those use
-    one of the supported event loops. It is easy to add new event loops to
+    with the rest: POE + EV? No go. Tk + Event? No go. Again: if your module
+    uses one of those, every user of your module has to use it, too. But if
+    your module uses AnyEvent, it works transparently with all event models
+    it supports (including stuff like IO::Async, as long as those use one of
+    the supported event loops. It is easy to add new event loops to
     AnyEvent, too, so it is future-proof).
 
     In addition to being free of having to use *the one and only true event
@@ -839,6 +839,8 @@
            AnyEvent::Impl::EventLib  based on Event::Lib, leaks memory and worse.
            AnyEvent::Impl::POE       based on POE, very slow, some limitations.
            AnyEvent::Impl::Irssi     used when running within irssi.
+           AnyEvent::Impl::IOAsync   based on IO::Async.
+           AnyEvent::Impl::Cocoa     based on Cocoa::EventLoop.
 
     Backends with special needs.
         Qt requires the Qt::Application to be instantiated first, but will
@@ -847,14 +849,6 @@
         created, everything should just work.
 
            AnyEvent::Impl::Qt        based on Qt.
-
-        Support for IO::Async can only be partial, as it is too broken and
-        architecturally limited to even support the AnyEvent API. It also is
-        the only event loop that needs the loop to be set explicitly, so it
-        can only be used by a main program knowing about AnyEvent. See
-        AnyEvent::Impl::IOAsync for the gory details.
-
-           AnyEvent::Impl::IOAsync   based on IO::Async, cannot be autoprobed.
 
     Event loops that are indirectly supported via other backends.
         Some event loops can be supported via other modules:

Modified: branches/upstream/libanyevent-perl/current/lib/AnyEvent.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/lib/AnyEvent.pm?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/lib/AnyEvent.pm (original)
+++ branches/upstream/libanyevent-perl/current/lib/AnyEvent.pm Sat Jan  1 02:28:34 2011
@@ -87,12 +87,12 @@
 
 AnyEvent is different: AnyEvent + POE works fine. AnyEvent + Glib works
 fine. AnyEvent + Tk works fine etc. etc. but none of these work together
-with the rest: POE + IO::Async? No go. Tk + Event? No go. Again: if
-your module uses one of those, every user of your module has to use it,
-too. But if your module uses AnyEvent, it works transparently with all
-event models it supports (including stuff like IO::Async, as long as those
-use one of the supported event loops. It is easy to add new event loops
-to AnyEvent, too, so it is future-proof).
+with the rest: POE + EV? No go. Tk + Event? No go. Again: if your module
+uses one of those, every user of your module has to use it, too. But if
+your module uses AnyEvent, it works transparently with all event models it
+supports (including stuff like IO::Async, as long as those use one of the
+supported event loops. It is easy to add new event loops to AnyEvent, too,
+so it is future-proof).
 
 In addition to being free of having to use I<the one and only true event
 model>, AnyEvent also is free of bloat and policy: with POE or similar
@@ -878,6 +878,8 @@
    AnyEvent::Impl::EventLib  based on Event::Lib, leaks memory and worse.
    AnyEvent::Impl::POE       based on POE, very slow, some limitations.
    AnyEvent::Impl::Irssi     used when running within irssi.
+   AnyEvent::Impl::IOAsync   based on IO::Async.
+   AnyEvent::Impl::Cocoa     based on Cocoa::EventLoop.
 
 =item Backends with special needs.
 
@@ -887,14 +889,6 @@
 everything should just work.
 
    AnyEvent::Impl::Qt        based on Qt.
-
-Support for IO::Async can only be partial, as it is too broken and
-architecturally limited to even support the AnyEvent API. It also
-is the only event loop that needs the loop to be set explicitly, so
-it can only be used by a main program knowing about AnyEvent. See
-L<AnyEvent::Impl::IOAsync> for the gory details.
-
-   AnyEvent::Impl::IOAsync   based on IO::Async, cannot be autoprobed.
 
 =item Event loops that are indirectly supported via other backends.
 
@@ -1169,7 +1163,7 @@
 
 use Carp ();
 
-our $VERSION = '5.29';
+our $VERSION = '5.3';
 our $MODEL;
 
 our $AUTOLOAD;
@@ -1217,14 +1211,8 @@
    [POE::Kernel::          => AnyEvent::Impl::POE::],      # lasciate ogni speranza
    [Wx::                   => AnyEvent::Impl::POE::],
    [Prima::                => AnyEvent::Impl::POE::],
-   # IO::Async is just too broken - we would need workarounds for its
-   # byzantine signal and broken child handling, among others.
-   # IO::Async is rather hard to detect, as it doesn't have any
-   # obvious default class.
-   [IO::Async::               => AnyEvent::Impl::IOAsync::], # requires special main program
-   [IO::Async::Loop::         => AnyEvent::Impl::IOAsync::], # requires special main program
-   [IO::Async::Notifier::     => AnyEvent::Impl::IOAsync::], # requires special main program
-   [AnyEvent::Impl::IOAsync:: => AnyEvent::Impl::IOAsync::], # requires special main program
+   [IO::Async::Loop::      => AnyEvent::Impl::IOAsync::],
+   [Cocoa::EventLoop::     => AnyEvent::Impl::Cocoa::],
 );
 
 our %method = map +($_ => 1),

Modified: branches/upstream/libanyevent-perl/current/lib/AnyEvent/FAQ.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/lib/AnyEvent/FAQ.pod?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/lib/AnyEvent/FAQ.pod (original)
+++ branches/upstream/libanyevent-perl/current/lib/AnyEvent/FAQ.pod Sat Jan  1 02:28:34 2011
@@ -98,7 +98,7 @@
 big deal - as soon as your program actually implements something sensible,
 CPU usage will be normal.
 
-=item Why does this FAQ not deal with L<AnyEvent::Handle> questions?
+=head2 Why does this FAQ not deal with L<AnyEvent::Handle> questions?
 
 Because L<AnyEvent::Handle> has a NONFAQ on it's own that already deals
 with common issues.

Modified: branches/upstream/libanyevent-perl/current/lib/AnyEvent/Handle.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/lib/AnyEvent/Handle.pm?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/lib/AnyEvent/Handle.pm (original)
+++ branches/upstream/libanyevent-perl/current/lib/AnyEvent/Handle.pm Sat Jan  1 02:28:34 2011
@@ -116,10 +116,10 @@
 =item on_prepare => $cb->($handle)
 
 This (rarely used) callback is called before a new connection is
-attempted, but after the file handle has been created. It could be used to
-prepare the file handle with parameters required for the actual connect
-(as opposed to settings that can be changed when the connection is already
-established).
+attempted, but after the file handle has been created (you can access that
+file handle via C<< $handle->{fh} >>). It could be used to prepare the
+file handle with parameters required for the actual connect (as opposed to
+settings that can be changed when the connection is already established).
 
 The return value of this callback should be the connect timeout value in
 seconds (or C<0>, or C<undef>, or the empty list, to indicate that the
@@ -280,6 +280,21 @@
 (for example, when expecting a line, an attacker could send an unlimited
 amount of data without a callback ever being called as long as the line
 isn't finished).
+
+=item wbuf_max => <bytes>
+
+If defined, then a fatal error will be raised (with C<$!> set to C<ENOSPC>)
+when the write buffer ever (strictly) exceeds this size. This is useful to
+avoid some forms of denial-of-service attacks.
+
+Although the units of this parameter is bytes, this is the I<raw> number
+of bytes not yet accepted by the kernel. This can make a difference when
+you e.g. use TLS, as TLS typically makes your write data larger (but it
+can also make it smaller due to compression).
+
+As an example of when this limit is useful, take a chat server that sends
+chat messages to a client. If the client does not read those in a timely
+manner then the send buffer in the server would grow unbounded.
 
 =item autocork => <boolean>
 
@@ -533,7 +548,7 @@
                   local $self->{fh} = $_[0];
 
                   $self->{on_prepare}
-                     ?  $self->{on_prepare}->($self)
+                     ? $self->{on_prepare}->($self)
                      : ()
                }
             );
@@ -742,10 +757,18 @@
 
 Configures the C<rbuf_max> setting (C<undef> disables it).
 
+=item $handle->wbuf_max ($max_octets)
+
+Configures the C<wbuf_max> setting (C<undef> disables it).
+
 =cut
 
 sub rbuf_max {
    $_[0]{rbuf_max} = $_[1];
+}
+
+sub rbuf_max {
+   $_[0]{wbuf_max} = $_[1];
 }
 
 #############################################################################
@@ -875,9 +898,9 @@
 
 =item $handle->push_write ($data)
 
-Queues the given scalar to be written. You can push as much data as you
-want (only limited by the available memory), as C<AnyEvent::Handle>
-buffers it independently of the kernel.
+Queues the given scalar to be written. You can push as much data as
+you want (only limited by the available memory and C<wbuf_max>), as
+C<AnyEvent::Handle> buffers it independently of the kernel.
 
 This method may invoke callbacks (and therefore the handle might be
 destroyed after it returns).
@@ -915,6 +938,13 @@
       # if still data left in wbuf, we need to poll
       $self->{_ww} = AE::io $self->{fh}, 1, $cb
          if length $self->{wbuf};
+
+      if (
+         defined $self->{wbuf_max}
+         && $self->{wbuf_max} < length $self->{wbuf}
+      ) {
+         $self->_error (Errno::ENOSPC, 1), return;
+      }
    };
 }
 

Added: branches/upstream/libanyevent-perl/current/lib/AnyEvent/Impl/Cocoa.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/lib/AnyEvent/Impl/Cocoa.pm?rev=66754&op=file
==============================================================================
--- branches/upstream/libanyevent-perl/current/lib/AnyEvent/Impl/Cocoa.pm (added)
+++ branches/upstream/libanyevent-perl/current/lib/AnyEvent/Impl/Cocoa.pm Sat Jan  1 02:28:34 2011
@@ -1,0 +1,70 @@
+=head1 NAME
+
+AnyEvent::Impl::Cocoa - AnyEvent adaptor for Cocoa::EventLoop
+
+=head1 SYNOPSIS
+
+    use AnyEvent;
+    use Cocoa::EventLoop;
+    
+    # do something
+
+=head1 DESCRIPTION
+
+This module provides NSRunLoop support to AnyEvent.
+
+NSRunLoop is an event loop for Cocoa applications, wrapped by
+L<Cocoa::EventLoop>. By using this module, you can use Cocoa based API in
+your AnyEvent application, or AnyEvent within Cocoa applications.
+
+=head1 BUGS
+
+Right now, L<Cocoa::EventLoop> (and this module) are in an early
+development phase and has some shortcomings and likely bugs.
+
+For example, there seems to be no way to just handle a single event
+with Cocoa (is there nothing they can implement properly?), so this
+module currently wakes up at least ten times a second when waiting for
+events. Also, events caused by timers might get delayed by up to 0.1
+seconds.
+
+=cut
+
+package AnyEvent::Impl::Cocoa;
+
+use AnyEvent (); BEGIN { AnyEvent::common_sense }
+
+use Cocoa::EventLoop;
+
+sub io {
+   my ($class, %arg) = @_;
+   Cocoa::EventLoop->io (%arg);
+}
+
+sub timer {
+   my ($class, %arg) = @_;
+   Cocoa::EventLoop->timer (%arg);
+}
+
+sub loop {
+   Cocoa::EventLoop->run;
+}
+
+sub one_event {
+   # this actually is not one event, but it's unable to handle it correctly at Cocoa 
+   Cocoa::EventLoop->run_while (0.1);
+}
+
+1;
+
+=head1 AUTHORS
+
+Daisuke Murase <typester at cpan.org>, Marc Lehmann <schmorp at schmorp.de>.
+
+=head1 COPYRIGHTS
+
+   Copyright (c) 2009 by KAYAC Inc.
+   Copyright (c) 2010 by Marc Lehmann <schmorp at schmorp.de>
+
+=cut
+

Modified: branches/upstream/libanyevent-perl/current/lib/AnyEvent/Impl/IOAsync.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/lib/AnyEvent/Impl/IOAsync.pm?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/lib/AnyEvent/Impl/IOAsync.pm (original)
+++ branches/upstream/libanyevent-perl/current/lib/AnyEvent/Impl/IOAsync.pm Sat Jan  1 02:28:34 2011
@@ -5,62 +5,30 @@
 =head1 SYNOPSIS
 
   use AnyEvent;
-
-  use IO::ASync::Loop;
+  use IO::Async::Loop;
+
+  # optionally set another event loop
   use AnyEvent::Impl::IOAsync;
-
   my $loop = new IO::Async::Loop;
-
   AnyEvent::Impl::IOAsync::set_loop $loop;
 
 =head1 DESCRIPTION
 
-This module provides support for IO::Async as AnyEvent backend. Due to
-the rather sad state of L<IO::Async>, support is only available partially
-(only timers and I/O watchers are supported, signals and child watchers
-are emulated by AnyEvent itself (fighting with IO::Async, so you cannot
-use both), idle watchers are being emulated, I/O watchers need to dup
-their fh.
+This module provides support for IO::Async as AnyEvent backend. It supports
+I/O, timers, signals and child process watchers. Idle watchers are emulated.
+I/O watchers need to dup their fh because IO::Async only supports IO handles,
+not plain file descriptors.
 
 =head1 PROBLEMS WITH IO::Async
 
-There have been multiple attempts at providing an AnyEvent interface to
-IO::Async, and the effort is ongoing. Supporting IO::Async is hard. Here's
-why:
+This section had a long list of problems and shortcomings that made it
+almost impossible to support L<IO::Async>. With version 0.33 of IO::Async,
+however, most of these have been fixed, so L<IO::Async> can now be used as
+easily as many other loops.
+
+There are a few remaining problems that require emulation or workarounds:
 
 =over 4
-
-=item IO::Async integration cannot be automatic - no default loop
-
-IO::Async doesn't offer an interface suitable for independent usage of
-event sources: there is no standard way to share the main event loop
-between modules - modules have to somehow agree on how to do this.
-
-For AnyEvent to work with IO::Async, the IO::Async main program has to
-call C<AnyEvent::Impl::IOAsync::set_loop> with the C<IO::Async::Loop>
-object that AnyEvent is to use, see the SYNOPSIS section for an example.
-
-It is possible to get a copy of the loop by reading
-C<$AnyEvent::Impl::IOAsync::LOOP>, so AnyEvent could be used as a central
-place to store the default L<IO::Async::Loop> object, also for other
-modules, if there is any need for that.
-
-=item Broken child watchers
-
-IO::Async is the only module that requires you to call a special function
-before even forking your child program, while the AnyEvent API itself
-(which works with other event loops) works as long as it has been
-initialised (AnyEvent's own pure perl implementation doesn't even suffer
-from these limitations and just works).
-
-Worse, IO::Async does not let you install multiple child watchers, does
-not let you watch for any child, and apparently an interface to unregister
-child watchers has been forgotten as well.
-
-As a result, AnyEvent::Impl::IOAsync has to fall back on its own child
-management, which makes it impossible to watch for child processes via
-both AnyEvent and IO::Async. Hooking and Patching IO::Async has been
-considered, but is considerable work.
 
 =item No support for multiple watchers per event
 
@@ -69,18 +37,9 @@
 classes when you cannot have multiple notifiers for the same event? That's
 like only allowing one timer per second or so...).
 
-This makes signal watchers almost useless (You could just hook them
-yourself, you can't share any of them, as would make sense for
-e.g. SIGTERM, SIGTSTP, SIGPWR, SIGUSR1 etc.).
-
-As a result, AnyEvent falls back to its own signal handling (it is
-pointless to somehow share the IO::Async watcher, as it doesn't matter if
-AnyEvent blocks the signal via IO::Async or directly, and AnyEvents signal
-handling is race-free).
-
 For I/O watchers, AnyEvent has to dup() every file handle, as IO::Async
 fails to support the same or different file handles pointing to the same
-fd (this is at least documented, but why not fix it instead?).
+fd (the good thing is that it is documented, but why not fix it instead?).
 
 =back
 
@@ -89,7 +48,7 @@
 
 =over 4
 
-=item Confusing and misleading name
+=item Confusing and misleading names
 
 Another rather negative point about this module family is its name,
 which is deeply confusing: Despite the "async" in the name, L<IO::Async>
@@ -104,24 +63,9 @@
 was a nightmare (try implementing a timer with configurable interval and
 delay value...).
 
-How to actually get I/O events in L<IO::Async::Handle> is undocumented:
-read events are apparently automatic, for write events, you have to
-explicitly request C<want_writeready>, and specifying C<want_readready> is
-apparently a usage bug (it doesn't exist). All this must be deduced from
-reading the sources.
-
-You can't stop child watchers. Even reading the sources I found no way to
-stop them. It must have been forgotten.
-
 The method naming is chaotic: C<watch_child> creates a child watcher,
 but C<watch_io> is an internal method; C<detach_signal> removes a signal
 watcher, but C<detach_child> forks a subprocess and so on).
-
-IO::Async has weird checks - passing in a callable reference is sometimes
-forbidden (of course, this is checked on every invocation, not when the
-callback is registered, so you have no idea where in your code you passed
-it in), as the code checks explicitly for code references, disallowing
-callable objects.
 
 =item Unpleasant surprises on GNU/Linux
 
@@ -135,20 +79,6 @@
 fork, which admittedly is hard - EV does it for you, and also does not use
 unsafe backends by default).
 
-=item Exiting considered harmful
-
-   (in cleanup) Can't call method "parent" on an undefined value
-      at IO/Async/Loop.pm line 297 during global destruction.
-
-IO::Async just hates global destruction. Calling C<exit> will easily give
-you one such line per watcher.
-
-The problem is that L<IO::Async::Loop> is itself not warning-free, but
-actually enables warnings for itself.
-
-(Ok, the real bug is of course perl's broken mark & sweep garbage
-collector that corrupts data structures).
-
 =back
 
 On the positive side, performance with IO::Async is quite good even in my
@@ -163,22 +93,12 @@
 use Time::HiRes;
 use Scalar::Util;
 
-BEGIN {
-   # IO::Async enables warnings but is itself not warning-free, we
-   # try our best to silence it.
-   require warnings;
-   local *warnings::import = sub { };
-   require IO::Async::Loop;
-}
-
-use IO::Async::Handle;
-
-our $VERSION = $AnyEvent::VERSION;
-our $LOOP;
+use IO::Async::Loop 0.33;
+
+our $LOOP = new IO::Async::Loop;
 
 sub set_loop($) {
    $LOOP = $_[0];
-   #$LOOP->enable_childmanager;
 }
 
 sub timer {
@@ -204,48 +124,62 @@
       $id = $LOOP->enqueue_timer (delay => $arg{after}, code => sub { &$cb });
    }
 
-   bless \\$id, "AnyEvent::Impl::IOAsync::timer"
+   bless \$id, "AnyEvent::Impl::IOAsync::timer"
 }
 
 sub AnyEvent::Impl::IOAsync::timer::DESTROY {
-   $LOOP->cancel_timer (${${$_[0]}});
+   # Need to be well-behaved during global destruction
+   $LOOP->cancel_timer (${$_[0]}) if ${$_[0]};
 }
 
 sub io {
    my ($class, %arg) = @_;
 
-   # we need to dup(), as IO::Async only allows one watcher per
-   # underlying fd.
+   # Ensure we have a real IO handle, and not just a UNIX fd integer
    my ($fh) = AnyEvent::_dupfh $arg{poll}, $arg{fh};
 
-   # there is no want_readready, but want_writeready is obligatory :/
-   # I just love undocumented and illogical interfaces...
-   my $id = new IO::Async::Handle
-      $arg{poll} eq "r"
-         ? (read_handle  => $fh, on_read_ready  => $arg{cb})
-         : (write_handle => $fh, on_write_ready => $arg{cb}, want_writeready => 1),
-   ;
-   $LOOP->add ($id);
-
-   bless \\$id, "AnyEvent::Impl::IOAsync::io"
+   my $event = $arg{poll} eq "r" ? "on_read_ready" : "on_write_ready";
+
+   $LOOP->watch_io (
+      handle => $fh,
+      $event => $arg{cb},
+   );
+
+   bless [$fh, $event], "AnyEvent::Impl::IOAsync::io"
 }
 
 sub AnyEvent::Impl::IOAsync::io::DESTROY {
-   $LOOP->remove (${${$_[0]}});
-}
-
-#sub signal {
-#   my ($class, %arg) = @_;
-#
-#   my $signal = $arg{signal};
-#
-#   my $id = $LOOP->attach_signal ($arg{signal}, $arg{cb});
-#   bless [$signal, $id], "AnyEvent::Impl::IOAsync::signal";
-#}
-#
-#sub AnyEvent::Impl::IOAsync::signal::DESTROY {
-#   $LOOP->detach_signal (@{ $_[0] });
-#}
+   $LOOP->unwatch_io (
+      handle => $_[0][0],
+      $_[0][1] => 1,
+   );
+}
+
+sub signal {
+   my ($class, %arg) = @_;
+
+   my $signal = $arg{signal};
+
+   my $id = $LOOP->attach_signal ($arg{signal}, $arg{cb});
+   bless [$signal, $id], "AnyEvent::Impl::IOAsync::signal";
+}
+
+sub AnyEvent::Impl::IOAsync::signal::DESTROY {
+   $LOOP->detach_signal (@{ $_[0] });
+}
+
+sub child {
+   my ($class, %arg) = @_;
+
+   my $pid = $arg{pid};
+
+   $LOOP->watch_child ($pid, $arg{cb});
+   bless [$pid], "AnyEvent::Impl::IOAsync::child";
+}
+
+sub AnyEvent::Impl::IOAsync::child::DESTROY {
+   $LOOP->unwatch_child (@{ $_[0] });
+}
 
 sub one_event {
    $LOOP->loop_once;
@@ -259,12 +193,15 @@
 
 =head1 SEE ALSO
 
-L<AnyEvent>, L<EV>.
+L<AnyEvent>, L<IO::Async>.
 
 =head1 AUTHOR
 
  Marc Lehmann <schmorp at schmorp.de>
  http://home.schmorp.de/
 
+ Paul Evans <leonerd at leonerd.org.uk>
+ Rewrote the backend for IO::Async version 0.33.
+
 =cut
 

Modified: branches/upstream/libanyevent-perl/current/lib/AnyEvent/Util.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/lib/AnyEvent/Util.pm?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/lib/AnyEvent/Util.pm (original)
+++ branches/upstream/libanyevent-perl/current/lib/AnyEvent/Util.pm Sat Jan  1 02:28:34 2011
@@ -513,12 +513,13 @@
 
 =item on_prepare => $cb
 
-Specify a callback that is executed just before the comamnd is C<exec>'ed,
+Specify a callback that is executed just before the command is C<exec>'ed,
 in the child process. Be careful not to use any event handling or other
 services not available in the child.
 
 This can be useful to set up the environment in special ways, such as
-changing the priority of the command.
+changing the priority of the command or manipulating signal handlers (e.g.
+setting C<SIGINT> to C<IGNORE>).
 
 =item close_all => $boolean
 
@@ -594,6 +595,8 @@
          } elsif (ref $ob) {
             my ($pr, $pw) = AnyEvent::Util::portable_pipe;
             $cv->begin;
+
+            fcntl $pr, AnyEvent::F_SETFD, AnyEvent::FD_CLOEXEC;
             my $w; $w = AE::io $pr, 0,
                "SCALAR" eq ref $ob
                   ? sub {
@@ -635,6 +638,7 @@
                $data = $ob->();
             }
 
+            fcntl $pw, AnyEvent::F_SETFD, AnyEvent::FD_CLOEXEC;
             my $w; $w = AE::io $pw, 1, sub {
                my $len = syswrite $pw, $data;
 

Modified: branches/upstream/libanyevent-perl/current/t/01_basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/t/01_basic.t?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/t/01_basic.t (original)
+++ branches/upstream/libanyevent-perl/current/t/01_basic.t Sat Jan  1 02:28:34 2011
@@ -1,5 +1,5 @@
 use AnyEvent;
-use AnyEvent::Impl::Perl;
+BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} }
 
 $| = 1; print "1..6\n";
 

Modified: branches/upstream/libanyevent-perl/current/t/02_signals.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/t/02_signals.t?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/t/02_signals.t (original)
+++ branches/upstream/libanyevent-perl/current/t/02_signals.t Sat Jan  1 02:28:34 2011
@@ -8,7 +8,7 @@
 }
 
 use AnyEvent;
-use AnyEvent::Impl::Perl;
+BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} }
 
 $| = 1; print "1..5\n";
 

Modified: branches/upstream/libanyevent-perl/current/t/03_child.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/t/03_child.t?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/t/03_child.t (original)
+++ branches/upstream/libanyevent-perl/current/t/03_child.t Sat Jan  1 02:28:34 2011
@@ -19,7 +19,7 @@
 }
 
 use AnyEvent;
-use AnyEvent::Impl::Perl;
+BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} }
 
 $| = 1; print "1..50\n";
 

Modified: branches/upstream/libanyevent-perl/current/t/04_condvar.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/t/04_condvar.t?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/t/04_condvar.t (original)
+++ branches/upstream/libanyevent-perl/current/t/04_condvar.t Sat Jan  1 02:28:34 2011
@@ -1,5 +1,5 @@
 use AnyEvent;
-use AnyEvent::Impl::Perl;
+BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} }
 
 $| = 1; print "1..21\n";
 

Modified: branches/upstream/libanyevent-perl/current/t/05_dns.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/t/05_dns.t?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/t/05_dns.t (original)
+++ branches/upstream/libanyevent-perl/current/t/05_dns.t Sat Jan  1 02:28:34 2011
@@ -1,7 +1,8 @@
 # we avoid complicated tests here because some systems will
 # not have working DNS
 
-use AnyEvent::Impl::Perl;
+use AnyEvent;
+BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} }
 use AnyEvent::DNS;
 
 $| = 1; print "1..5\n";

Modified: branches/upstream/libanyevent-perl/current/t/07_io.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/t/07_io.t?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/t/07_io.t (original)
+++ branches/upstream/libanyevent-perl/current/t/07_io.t Sat Jan  1 02:28:34 2011
@@ -1,6 +1,6 @@
 use AnyEvent;
 use AnyEvent::Util;
-use AnyEvent::Impl::Perl;
+BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} }
 
 $| = 1; print "1..18\n";
 

Modified: branches/upstream/libanyevent-perl/current/t/08_idna.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/t/08_idna.t?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/t/08_idna.t (original)
+++ branches/upstream/libanyevent-perl/current/t/08_idna.t Sat Jan  1 02:28:34 2011
@@ -1,4 +1,6 @@
 use utf8;
+
+use AnyEvent;
 use AnyEvent::Util;
 
 $| = 1; print "1..11\n";

Modified: branches/upstream/libanyevent-perl/current/t/handle/01_readline.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/t/handle/01_readline.t?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/t/handle/01_readline.t (original)
+++ branches/upstream/libanyevent-perl/current/t/handle/01_readline.t Sat Jan  1 02:28:34 2011
@@ -4,7 +4,8 @@
 
 use strict;
 
-use AnyEvent::Impl::Perl;
+use AnyEvent;
+BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} }
 use AnyEvent::Handle;
 use Test::More tests => 8;
 use Socket;

Modified: branches/upstream/libanyevent-perl/current/t/handle/02_write.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/t/handle/02_write.t?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/t/handle/02_write.t (original)
+++ branches/upstream/libanyevent-perl/current/t/handle/02_write.t Sat Jan  1 02:28:34 2011
@@ -2,7 +2,8 @@
 
 use strict;
 
-use AnyEvent::Impl::Perl;
+use AnyEvent;
+BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} }
 use AnyEvent::Handle;
 use Socket;
 

Modified: branches/upstream/libanyevent-perl/current/t/handle/03_http_req.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/t/handle/03_http_req.t?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/t/handle/03_http_req.t (original)
+++ branches/upstream/libanyevent-perl/current/t/handle/03_http_req.t Sat Jan  1 02:28:34 2011
@@ -2,8 +2,8 @@
 
 use strict;
 
-use AnyEvent::Impl::Perl;
 use AnyEvent;
+BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} }
 use AnyEvent::Socket;
 use AnyEvent::Handle;
 

Modified: branches/upstream/libanyevent-perl/current/t/handle/04_listen.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libanyevent-perl/current/t/handle/04_listen.t?rev=66754&op=diff
==============================================================================
--- branches/upstream/libanyevent-perl/current/t/handle/04_listen.t (original)
+++ branches/upstream/libanyevent-perl/current/t/handle/04_listen.t Sat Jan  1 02:28:34 2011
@@ -2,10 +2,10 @@
 
 use strict;
 
-use AnyEvent::Impl::Perl;
+use AnyEvent;
+BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} }
 use AnyEvent::Handle;
 use AnyEvent::Socket;
-use AnyEvent;
 
 my $lbytes;
 my $rbytes;




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