--- AnyEvent/lib/AnyEvent/Handle.pm 2010/12/31 04:47:41 1.211 +++ AnyEvent/lib/AnyEvent/Handle.pm 2011/02/24 12:04:20 1.218 @@ -249,22 +249,27 @@ will be invoked (and if that one is missing, a non-fatal C error will be raised). -There are three variants of the timeouts that work independently -of each other, for both read and write, just read, and just write: +There are three variants of the timeouts that work independently of each +other, for both read and write (triggered when nothing was read I +written), just read (triggered when nothing was read), and just write: C, C and C, with corresponding callbacks C, C and C, and reset functions C, C, and C. -Note that timeout processing is active even when you do not have -any outstanding read or write requests: If you plan to keep the connection -idle then you should disable the timeout temporarily or ignore the timeout -in the C callback, in which case AnyEvent::Handle will simply -restart the timeout. +Note that timeout processing is active even when you do not have any +outstanding read or write requests: If you plan to keep the connection +idle then you should disable the timeout temporarily or ignore the +timeout in the corresponding C callback, in which case +AnyEvent::Handle will simply restart the timeout. -Zero (the default) disables this timeout. +Zero (the default) disables the corresponding timeout. =item on_timeout => $cb->($handle) +=item on_rtimeout => $cb->($handle) + +=item on_wtimeout => $cb->($handle) + Called whenever the inactivity timeout passes. If you return from this callback, then the timeout will be reset as if some activity had happened, so this condition is not fatal in any way. @@ -538,7 +543,7 @@ } else { if ($self->{on_connect_error}) { $self->{on_connect_error}($self, "$!"); - $self->destroy; + $self->destroy if $self; } else { $self->_error ($!, 1); } @@ -767,7 +772,7 @@ $_[0]{rbuf_max} = $_[1]; } -sub rbuf_max { +sub wbuf_max { $_[0]{wbuf_max} = $_[1]; } @@ -781,6 +786,9 @@ Configures (or disables) the inactivity timeout. +The timeout will be checked instantly, so this method might destroy the +handle before it returns. + =item $handle->timeout_reset =item $handle->rtimeout_reset @@ -1089,7 +1097,7 @@ C to C<0>). This method is a shorthand for just that, and replaces the C callback with: - sub { shutdown $_[0]{fh}, 1 } # for push_shutdown + sub { shutdown $_[0]{fh}, 1 } This simply shuts down the write side and signals an EOF condition to the the peer. @@ -1618,9 +1626,7 @@ defined (my $len = eval { unpack $format, $_[0]{rbuf} }) or return; - warn "len $len\n";#d# $format = length pack $format, $len; - warn "len2 $format\n";#d# # bypass unshift if we already have the remaining chunk if ($format + $len <= length $_[0]{rbuf}) { @@ -1777,15 +1783,24 @@ will automatically C for you when neither C is set nor there are any read requests in the queue. -These methods will have no effect when in TLS mode (as TLS doesn't support -half-duplex connections). +In older versions of this module (<= 5.3), these methods had no effect, +as TLS does not support half-duplex connections. In current versions they +work as expected, as this behaviour is required to avoid certain resource +attacks, where the program would be forced to read (and buffer) arbitrary +amounts of data before being able to send some data. The drawback is that +some readings of the the SSL/TLS specifications basically require this +attack to be working, as SSL/TLS implementations might stall sending data +during a rehandshake. + +As a guideline, during the initial handshake, you should not stop reading, +and as a client, it might cause problems, depending on your applciation. =cut sub stop_read { my ($self) = @_; - delete $self->{_rw} unless $self->{tls}; + delete $self->{_rw}; } sub start_read { @@ -2045,6 +2060,19 @@ delete @$self{qw(_rbio _wbio _tls_wbuf _on_starttls)}; } +=item $handle->resettls + +This rarely-used method simply resets and TLS state on the handle, usually +causing data loss. + +One case where it may be useful is when you want to skip over the data in +the stream but you are not interested in interpreting it, so data loss is +no concern. + +=cut + +*resettls = \&_freetls; + sub DESTROY { my ($self) = @_;