r41428 - in /trunk/libanyevent-perl: Changes META.yml debian/changelog lib/AnyEvent.pm lib/AnyEvent/DNS.pm lib/AnyEvent/Handle.pm lib/AnyEvent/Impl/Perl.pm lib/AnyEvent/Socket.pm lib/AnyEvent/TLS.pm lib/AnyEvent/Util.pm
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Thu Aug 6 22:56:44 UTC 2009
Author: jawnsy-guest
Date: Thu Aug 6 22:56:38 2009
New Revision: 41428
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=41428
Log:
* New upstream release
+ Prevent AE::Handle::starttls from becoming out of sync when the read
buffer already contains some TLS handshake
+ AE::Handle did not properly free the TLS session, causing bigger memory
leaks in Net::SSLeay than expected
+ AE::Socket::tcp_connect now artificially delays invocation of callback
to avoid returning afterward
+ Convert many internal watcher uses to the AnyEvent API
Modified:
trunk/libanyevent-perl/Changes
trunk/libanyevent-perl/META.yml
trunk/libanyevent-perl/debian/changelog
trunk/libanyevent-perl/lib/AnyEvent.pm
trunk/libanyevent-perl/lib/AnyEvent/DNS.pm
trunk/libanyevent-perl/lib/AnyEvent/Handle.pm
trunk/libanyevent-perl/lib/AnyEvent/Impl/Perl.pm
trunk/libanyevent-perl/lib/AnyEvent/Socket.pm
trunk/libanyevent-perl/lib/AnyEvent/TLS.pm
trunk/libanyevent-perl/lib/AnyEvent/Util.pm
Modified: trunk/libanyevent-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-perl/Changes?rev=41428&op=diff
==============================================================================
--- trunk/libanyevent-perl/Changes (original)
+++ trunk/libanyevent-perl/Changes Thu Aug 6 22:56:38 2009
@@ -1,4 +1,13 @@
Revision history for Perl extension AnyEvent.
+
+4.91 Thu Aug 6 15:42:45 CEST 2009
+ - AE::Handle::starttls could get out of sync when the read buffer
+ already contains some TLS handshake.
+ - AE::Handle did not properly free the TLS session, causing bigger
+ memory leaks in Net::SSLeay than expected (reported by toaster).
+ - AE::Socket::tcp_connect will now artificially delay invoking
+ the callback to avoid returning after invoking the callback.
+ - convert many internal watcher uses to AE API.
4.9 Sat Aug 1 11:07:01 CEST 2009
- Glib silently fails when registering a timeout with
Modified: trunk/libanyevent-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-perl/META.yml?rev=41428&op=diff
==============================================================================
--- trunk/libanyevent-perl/META.yml (original)
+++ trunk/libanyevent-perl/META.yml Thu Aug 6 22:56:38 2009
@@ -11,7 +11,7 @@
},
"generated_by" : "ExtUtils::MakeMaker version 6.50",
"distribution_type" : "module",
- "version" : "4.9",
+ "version" : "4.91",
"name" : "AnyEvent",
"author" : [],
"license" : "unknown",
Modified: trunk/libanyevent-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-perl/debian/changelog?rev=41428&op=diff
==============================================================================
--- trunk/libanyevent-perl/debian/changelog (original)
+++ trunk/libanyevent-perl/debian/changelog Thu Aug 6 22:56:38 2009
@@ -1,3 +1,16 @@
+libanyevent-perl (4.910-1) UNRELEASED; urgency=low
+
+ * New upstream release
+ + Prevent AE::Handle::starttls from becoming out of sync when the read
+ buffer already contains some TLS handshake
+ + AE::Handle did not properly free the TLS session, causing bigger memory
+ leaks in Net::SSLeay than expected
+ + AE::Socket::tcp_connect now artificially delays invocation of callback
+ to avoid returning afterward
+ + Convert many internal watcher uses to the AnyEvent API
+
+ -- Jonathan Yu <frequency at cpan.org> Thu, 06 Aug 2009 14:56:21 -0400
+
libanyevent-perl (4.900-1) unstable; urgency=low
* New upstream release
Modified: trunk/libanyevent-perl/lib/AnyEvent.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-perl/lib/AnyEvent.pm?rev=41428&op=diff
==============================================================================
--- trunk/libanyevent-perl/lib/AnyEvent.pm (original)
+++ trunk/libanyevent-perl/lib/AnyEvent.pm Thu Aug 6 22:56:38 2009
@@ -1117,7 +1117,7 @@
use Carp ();
-our $VERSION = 4.9;
+our $VERSION = 4.91;
our $MODEL;
our $AUTOLOAD;
@@ -1289,6 +1289,48 @@
($fh2, $rw)
}
+#############################################################################
+# "new" API, currently only emulation of it
+#############################################################################
+
+package AE;
+
+sub io($$$) {
+ AnyEvent->io (fh => $_[0], poll => $_[1] ? "w" : "r", cb => $_[2])
+}
+
+sub timer($$$) {
+ AnyEvent->timer (after => $_[0], interval => $_[1], cb => $_[2]);
+}
+
+sub signal($$) {
+ AnyEvent->signal (signal => $_[0], cb => $_[1]);
+}
+
+sub child($$) {
+ AnyEvent->child (pid => $_[0], cb => $_[1]);
+}
+
+sub idle($) {
+ AnyEvent->idle (cb => $_[0]);
+}
+
+sub cv(;&) {
+ AnyEvent->condvar (@_ ? (cb => $_[0]) : ())
+}
+
+sub now() {
+ AnyEvent->now
+}
+
+sub now_update() {
+ AnyEvent->now_update
+}
+
+sub time() {
+ AnyEvent->time
+}
+
package AnyEvent::Base;
# default implementations for many methods
@@ -1350,13 +1392,13 @@
sub _sig_add() {
unless ($SIG_COUNT++) {
# try to align timer on a full-second boundary, if possible
- my $NOW = AnyEvent->now;
-
- $SIG_TW = AnyEvent->timer (
- after => $MAX_SIGNAL_LATENCY - ($NOW - int $NOW),
- interval => $MAX_SIGNAL_LATENCY,
- cb => sub { }, # just for the PERL_ASYNC_CHECK
- );
+ my $NOW = AE::now;
+
+ $SIG_TW = AE::timer
+ $MAX_SIGNAL_LATENCY - ($NOW - int $NOW),
+ $MAX_SIGNAL_LATENCY,
+ sub { } # just for the PERL_ASYNC_CHECK
+ ;
}
}
@@ -1403,7 +1445,7 @@
warn "AnyEvent: using Async::Interrupt for race-free signal handling.\n" if $VERBOSE >= 8;
$SIGPIPE_R = new Async::Interrupt::EventPipe;
- $SIG_IO = AnyEvent->io (fh => $SIGPIPE_R->fileno, poll => "r", cb => \&_signal_exec);
+ $SIG_IO = AE::io $SIGPIPE_R->fileno, 0, \&_signal_exec;
} else {
warn "AnyEvent: using emulated perl signal handling with latency timer.\n" if $VERBOSE >= 8;
@@ -1429,7 +1471,7 @@
$SIGPIPE_R
or Carp::croak "AnyEvent: unable to create a signal reporting pipe: $!\n";
- $SIG_IO = AnyEvent->io (fh => $SIGPIPE_R, poll => "r", cb => \&_signal_exec);
+ $SIG_IO = AE::io $SIGPIPE_R, 0, \&_signal_exec;
}
*signal = sub {
@@ -1528,7 +1570,7 @@
: eval { local $SIG{__DIE__}; require POSIX; &POSIX::WNOHANG } || 1;
unless ($CHLD_W) {
- $CHLD_W = AnyEvent->signal (signal => 'CHLD', cb => \&_sigchld);
+ $CHLD_W = AE::signal CHLD => \&_sigchld;
# child could be a zombie already, so make at least one round
&_sigchld;
}
@@ -1564,7 +1606,7 @@
$w = 0.0001 if $w < 0.0001;
$w = 5 if $w > 5;
- $w = AnyEvent->timer (after => $w, cb => $rcb);
+ $w = AE::timer $w, 0, $rcb;
} else {
# clean up...
undef $w;
@@ -1572,7 +1614,7 @@
}
};
- $w = AnyEvent->timer (after => 0.05, cb => $rcb);
+ $w = AE::timer 0.05, 0, $rcb;
bless \\$cb, "AnyEvent::Base::idle"
}
@@ -1659,48 +1701,6 @@
# undocumented/compatibility with pre-3.4
*broadcast = \&send;
*wait = \&_wait;
-
-#############################################################################
-# "new" API, currently only emulation of it
-#############################################################################
-
-package AE;
-
-sub io($$$) {
- AnyEvent->io (fh => $_[0], poll => $_[1] ? "w" : "r", cb => $_[2])
-}
-
-sub timer($$$) {
- AnyEvent->timer (after => $_[0], interval => $_[1], cb => $_[2]);
-}
-
-sub signal($$) {
- AnyEvent->signal (signal => $_[0], cb => $_[1]);
-}
-
-sub child($$) {
- AnyEvent->child (pid => $_[0], cb => $_[1]);
-}
-
-sub idle($) {
- AnyEvent->idle (cb => $_[0]);
-}
-
-sub cv() {
- AnyEvent->condvar
-}
-
-sub now() {
- AnyEvent->now
-}
-
-sub now_update() {
- AnyEvent->now_update
-}
-
-sub time() {
- AnyEvent->time
-}
=head1 ERROR AND EXCEPTION HANDLING
Modified: trunk/libanyevent-perl/lib/AnyEvent/DNS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-perl/lib/AnyEvent/DNS.pm?rev=41428&op=diff
==============================================================================
--- trunk/libanyevent-perl/lib/AnyEvent/DNS.pm (original)
+++ trunk/libanyevent-perl/lib/AnyEvent/DNS.pm Thu Aug 6 22:56:38 2009
@@ -34,7 +34,7 @@
use AnyEvent (); BEGIN { AnyEvent::common_sense }
use AnyEvent::Util qw(AF_INET6);
-our $VERSION = 4.9;
+our $VERSION = 4.91;
our @DNS_FALLBACK = (v208.67.220.220, v208.67.222.222);
@@ -764,11 +764,11 @@
AnyEvent::Util::fh_nonblocking $fh4, 1;
$self->{fh4} = $fh4;
- $self->{rw4} = AnyEvent->io (fh => $fh4, poll => "r", cb => sub {
+ $self->{rw4} = AE::io $fh4, 0, sub {
if (my $peer = recv $fh4, my $pkt, MAX_PKT, 0) {
$wself->_recv ($pkt, $peer);
}
- });
+ };
}
if (AF_INET6 && socket my $fh6, AF_INET6, &Socket::SOCK_DGRAM, 0) {
@@ -776,11 +776,11 @@
$self->{fh6} = $fh6;
AnyEvent::Util::fh_nonblocking $fh6, 1;
- $self->{rw6} = AnyEvent->io (fh => $fh6, poll => "r", cb => sub {
+ $self->{rw6} = AE::io $fh6, 0, sub {
if (my $peer = recv $fh6, my $pkt, MAX_PKT, 0) {
$wself->_recv ($pkt, $peer);
}
- });
+ };
}
$got_socket
@@ -1036,7 +1036,7 @@
my ($server, $timeout) = @$retry_cfg;
- $self->{id}{$req->[2]} = [AnyEvent->timer (after => $timeout, cb => sub {
+ $self->{id}{$req->[2]} = [(AE::timer $timeout, 0, sub {
$NOW = time;
# timeout, try next
@@ -1108,10 +1108,10 @@
if (@{ $self->{reuse_q} } >= 30000) {
# we ran out of ID's, wait a bit
- $self->{reuse_to} ||= AnyEvent->timer (after => $self->{reuse_q}[0][0] - $NOW, cb => sub {
+ $self->{reuse_to} ||= AE::timer $self->{reuse_q}[0][0] - $NOW, 0, sub {
delete $self->{reuse_to};
$self->_scheduler;
- });
+ };
last;
}
Modified: trunk/libanyevent-perl/lib/AnyEvent/Handle.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-perl/lib/AnyEvent/Handle.pm?rev=41428&op=diff
==============================================================================
--- trunk/libanyevent-perl/lib/AnyEvent/Handle.pm (original)
+++ trunk/libanyevent-perl/lib/AnyEvent/Handle.pm Thu Aug 6 22:56:38 2009
@@ -13,7 +13,7 @@
=cut
-our $VERSION = 4.9;
+our $VERSION = 4.91;
=head1 SYNOPSIS
@@ -1734,6 +1734,8 @@
$self->{_rbio} = Net::SSLeay::BIO_new (Net::SSLeay::BIO_s_mem ());
$self->{_wbio} = Net::SSLeay::BIO_new (Net::SSLeay::BIO_s_mem ());
+ Net::SSLeay::BIO_write ($self->{_rbio}, delete $self->{rbuf});
+
Net::SSLeay::set_bio ($tls, $self->{_rbio}, $self->{_wbio});
$self->{_on_starttls} = sub { $_[0]{on_starttls}(@_) }
@@ -1772,7 +1774,7 @@
return unless $self->{tls};
$self->{tls_ctx}->_put_session (delete $self->{tls})
- if ref $self->{tls};
+ if $self->{tls} > 0;
delete @$self{qw(_rbio _wbio _tls_wbuf _on_starttls)};
}
Modified: trunk/libanyevent-perl/lib/AnyEvent/Impl/Perl.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-perl/lib/AnyEvent/Impl/Perl.pm?rev=41428&op=diff
==============================================================================
--- trunk/libanyevent-perl/lib/AnyEvent/Impl/Perl.pm (original)
+++ trunk/libanyevent-perl/lib/AnyEvent/Impl/Perl.pm Thu Aug 6 22:56:38 2009
@@ -110,7 +110,7 @@
use AnyEvent (); BEGIN { AnyEvent::common_sense }
use AnyEvent::Util ();
-our $VERSION = 4.9;
+our $VERSION = 4.91;
our ($NOW, $MNOW);
Modified: trunk/libanyevent-perl/lib/AnyEvent/Socket.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-perl/lib/AnyEvent/Socket.pm?rev=41428&op=diff
==============================================================================
--- trunk/libanyevent-perl/lib/AnyEvent/Socket.pm (original)
+++ trunk/libanyevent-perl/lib/AnyEvent/Socket.pm Thu Aug 6 22:56:38 2009
@@ -58,7 +58,18 @@
tcp_connect
);
-our $VERSION = 4.9;
+our $VERSION = 4.91;
+
+# used in cases where we may return immediately but want the
+# caller to do stuff first
+sub _postpone {
+ my ($cb, @args) = @_;
+
+ my $w; $w = AE::timer 0, 0, sub {
+ undef $w;
+ $cb->(@args);
+ };
+}
=item $ipn = parse_ipv4 $dotted_quad
@@ -595,7 +606,7 @@
# resolve a records / provide sockaddr structures
my $resolve = sub {
my @res;
- my $cv = AnyEvent->condvar (cb => sub {
+ my $cv = AE::cv {
$cb->(
map $_->[2],
sort {
@@ -604,7 +615,7 @@
}
@res
)
- });
+ };
$cv->begin;
for my $idx (0 .. $#target) {
@@ -693,20 +704,24 @@
hosts or hosts with both IPv4 and IPv6 addresses) and try to connect to
each in turn.
-If the connect is successful, then the C<$connect_cb> will be invoked with
-the socket file handle (in non-blocking mode) as first and the peer host
-(as a textual IP address) and peer port as second and third arguments,
-respectively. The fourth argument is a code reference that you can call
-if, for some reason, you don't like this connection, which will cause
-C<tcp_connect> to try the next one (or call your callback without any
-arguments if there are no more connections). In most cases, you can simply
-ignore this argument.
+After the connection is established, then the C<$connect_cb> will be
+invoked with the socket file handle (in non-blocking mode) as first and
+the peer host (as a textual IP address) and peer port as second and third
+arguments, respectively. The fourth argument is a code reference that you
+can call if, for some reason, you don't like this connection, which will
+cause C<tcp_connect> to try the next one (or call your callback without
+any arguments if there are no more connections). In most cases, you can
+simply ignore this argument.
$cb->($filehandle, $host, $port, $retry)
If the connect is unsuccessful, then the C<$connect_cb> will be invoked
without any arguments and C<$!> will be set appropriately (with C<ENXIO>
indicating a DNS resolution failure).
+
+The callback will I<never> be invoked before C<tcp_connect> returns, even
+if C<tcp_connect> was able to connect immediately (e.g. on unix domain
+sockets).
The file handle is perfect for being plugged into L<AnyEvent::Handle>, but
can be used as a normal perl file handle as well.
@@ -809,7 +824,7 @@
return unless exists $state{fh};
my $target = shift @target
- or return (%state = (), $connect->());
+ or return (%state = (), _postpone $connect);
my ($domain, $type, $proto, $sockaddr) = @$target;
@@ -823,47 +838,44 @@
$timeout ||= 30 if AnyEvent::WIN32;
- $state{to} = AnyEvent->timer (after => $timeout, cb => sub {
+ $state{to} = AE::timer $timeout, 0, sub {
$! = Errno::ETIMEDOUT;
$state{next}();
- }) if $timeout;
-
- # called when the connect was successful, which,
- # in theory, could be the case immediately (but never is in practise)
- $state{connected} = sub {
- # we are connected, or maybe there was an error
- if (my $sin = getpeername $state{fh}) {
- my ($port, $host) = unpack_sockaddr $sin;
-
- delete $state{ww}; delete $state{to};
-
- my $guard = guard { %state = () };
-
- $connect->(delete $state{fh}, format_address $host, $port, sub {
- $guard->cancel;
+ } if $timeout;
+
+ # now connect
+ if (
+ (connect $state{fh}, $sockaddr)
+ || ($! == Errno::EINPROGRESS # POSIX
+ || $! == Errno::EWOULDBLOCK
+ # WSAEINPROGRESS intentionally not checked - it means something else entirely
+ || $! == AnyEvent::Util::WSAEINVAL # not convinced, but doesn't hurt
+ || $! == AnyEvent::Util::WSAEWOULDBLOCK)
+ ) {
+ $state{ww} = AE::io $state{fh}, 1, sub {
+ # we are connected, or maybe there was an error
+ if (my $sin = getpeername $state{fh}) {
+ my ($port, $host) = unpack_sockaddr $sin;
+
+ delete $state{ww}; delete $state{to};
+
+ my $guard = guard { %state = () };
+
+ $connect->(delete $state{fh}, format_address $host, $port, sub {
+ $guard->cancel;
+ $state{next}();
+ });
+ } else {
+ # dummy read to fetch real error code
+ sysread $state{fh}, my $buf, 1 if $! == Errno::ENOTCONN;
+
+ return if $! == Errno::EAGAIN; # skip spurious wake-ups
+
+ delete $state{ww}; delete $state{to};
+
$state{next}();
- });
- } else {
- # dummy read to fetch real error code
- sysread $state{fh}, my $buf, 1 if $! == Errno::ENOTCONN;
-
- return if $! == Errno::EAGAIN; # skip spurious wake-ups
-
- delete $state{ww}; delete $state{to};
-
- $state{next}();
- }
- };
-
- # now connect
- if (connect $state{fh}, $sockaddr) {
- $state{connected}->();
- } elsif ($! == Errno::EINPROGRESS # POSIX
- || $! == Errno::EWOULDBLOCK
- # WSAEINPROGRESS intentionally not checked - it means something else entirely
- || $! == AnyEvent::Util::WSAEINVAL # not convinced, but doesn't hurt
- || $! == AnyEvent::Util::WSAEWOULDBLOCK) {
- $state{ww} = AnyEvent->io (fh => $state{fh}, poll => 'w', cb => $state{connected});
+ }
+ };
} else {
$state{next}();
}
@@ -997,7 +1009,7 @@
listen $state{fh}, $len
or Carp::croak "listen: $!";
- $state{aw} = AnyEvent->io (fh => $state{fh}, poll => 'r', cb => sub {
+ $state{aw} = AE::io $state{fh}, 0, sub {
# this closure keeps $state alive
while (my $peer = accept my $fh, $state{fh}) {
fh_nonblocking $fh, 1; # POSIX requires inheritance, the outside world does not
@@ -1005,7 +1017,7 @@
my ($service, $host) = unpack_sockaddr $peer;
$accept->($fh, format_address $host, $service);
}
- });
+ };
defined wantarray
? guard { %state = () } # clear fh and watcher, which breaks the circular dependency
Modified: trunk/libanyevent-perl/lib/AnyEvent/TLS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-perl/lib/AnyEvent/TLS.pm?rev=41428&op=diff
==============================================================================
--- trunk/libanyevent-perl/lib/AnyEvent/TLS.pm (original)
+++ trunk/libanyevent-perl/lib/AnyEvent/TLS.pm Thu Aug 6 22:56:38 2009
@@ -14,7 +14,7 @@
=cut
-our $VERSION = 4.9;
+our $VERSION = 4.91;
=head1 SYNOPSIS
Modified: trunk/libanyevent-perl/lib/AnyEvent/Util.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-perl/lib/AnyEvent/Util.pm?rev=41428&op=diff
==============================================================================
--- trunk/libanyevent-perl/lib/AnyEvent/Util.pm (original)
+++ trunk/libanyevent-perl/lib/AnyEvent/Util.pm Thu Aug 6 22:56:38 2009
@@ -31,7 +31,7 @@
our @EXPORT = qw(fh_nonblocking guard fork_call portable_pipe portable_socketpair);
our @EXPORT_OK = qw(AF_INET6 WSAEWOULDBLOCK WSAEINPROGRESS WSAEINVAL);
-our $VERSION = 4.9;
+our $VERSION = 4.91;
BEGIN {
my $af_inet6 = eval { local $SIG{__DIE__}; &Socket::AF_INET6 };
More information about the Pkg-perl-cvs-commits
mailing list