ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Handle.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/Handle.pm (file contents):
Revision 1.55 by root, Tue Jun 3 16:15:30 2008 UTC vs.
Revision 1.56 by root, Wed Jun 4 09:55:16 2008 UTC

339 $self->{on_timeout}($self); 339 $self->{on_timeout}($self);
340 } else { 340 } else {
341 $self->_error (&Errno::ETIMEDOUT); 341 $self->_error (&Errno::ETIMEDOUT);
342 } 342 }
343 343
344 # callbakx could have changed timeout value, optimise 344 # callback could have changed timeout value, optimise
345 return unless $self->{timeout}; 345 return unless $self->{timeout};
346 346
347 # calculate new after 347 # calculate new after
348 $after = $self->{timeout}; 348 $after = $self->{timeout};
349 } 349 }
350 350
351 Scalar::Util::weaken $self; 351 Scalar::Util::weaken $self;
352 return unless $self; # ->error could have destroyed $self
352 353
353 $self->{_tw} ||= AnyEvent->timer (after => $after, cb => sub { 354 $self->{_tw} ||= AnyEvent->timer (after => $after, cb => sub {
354 delete $self->{_tw}; 355 delete $self->{_tw};
355 $self->_timeout; 356 $self->_timeout;
356 }); 357 });
1036In rare cases you actually do not want to read anything from the 1037In rare cases you actually do not want to read anything from the
1037socket. In this case you can call C<stop_read>. Neither C<on_read> no 1038socket. In this case you can call C<stop_read>. Neither C<on_read> no
1038any queued callbacks will be executed then. To start reading again, call 1039any queued callbacks will be executed then. To start reading again, call
1039C<start_read>. 1040C<start_read>.
1040 1041
1042Note that AnyEvent::Handle will automatically C<start_read> for you when
1043you change the C<on_read> callback or push/unshift a read callback, and it
1044will automatically C<stop_read> for you when neither C<on_read> is set nor
1045there are any read requests in the queue.
1046
1041=cut 1047=cut
1042 1048
1043sub stop_read { 1049sub stop_read {
1044 my ($self) = @_; 1050 my ($self) = @_;
1045 1051
1076} 1082}
1077 1083
1078sub _dotls { 1084sub _dotls {
1079 my ($self) = @_; 1085 my ($self) = @_;
1080 1086
1087 my $buf;
1088
1081 if (length $self->{_tls_wbuf}) { 1089 if (length $self->{_tls_wbuf}) {
1082 while ((my $len = Net::SSLeay::write ($self->{tls}, $self->{_tls_wbuf})) > 0) { 1090 while ((my $len = Net::SSLeay::write ($self->{tls}, $self->{_tls_wbuf})) > 0) {
1083 substr $self->{_tls_wbuf}, 0, $len, ""; 1091 substr $self->{_tls_wbuf}, 0, $len, "";
1084 } 1092 }
1085 } 1093 }
1086 1094
1087 if (defined (my $buf = Net::SSLeay::BIO_read ($self->{_wbio}))) { 1095 if (length ($buf = Net::SSLeay::BIO_read ($self->{_wbio}))) {
1088 $self->{wbuf} .= $buf; 1096 $self->{wbuf} .= $buf;
1089 $self->_drain_wbuf; 1097 $self->_drain_wbuf;
1090 } 1098 }
1091 1099
1092 while (defined (my $buf = Net::SSLeay::read ($self->{tls}))) { 1100 while (defined ($buf = Net::SSLeay::read ($self->{tls}))) {
1101 if (length $buf) {
1093 $self->{rbuf} .= $buf; 1102 $self->{rbuf} .= $buf;
1094 $self->_drain_rbuf; 1103 $self->_drain_rbuf;
1104 } else {
1105 # let's treat SSL-eof as we treat normal EOF
1106 $self->{_eof} = 1;
1107 $self->_shutdown;
1108 return;
1109 }
1095 } 1110 }
1096 1111
1097 my $err = Net::SSLeay::get_error ($self->{tls}, -1); 1112 my $err = Net::SSLeay::get_error ($self->{tls}, -1);
1098 1113
1099 if ($err!= Net::SSLeay::ERROR_WANT_READ ()) { 1114 if ($err!= Net::SSLeay::ERROR_WANT_READ ()) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines