Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(69)

Side by Side Diff: lib/DJabberd/Connection.pm

Issue 2341: avoid ssl_eof error on SSL_WANT_READ and friends SVN Base: http://code.sixapart.com/svn/djabberd/trunk/DJabberd
Patch Set: response to comments Created 1 year, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 package DJabberd::Connection; 1 package DJabberd::Connection;
2 use strict; 2 use strict;
3 use warnings; 3 use warnings;
4 use base 'Danga::Socket'; 4 use base 'Danga::Socket';
5 use bytes; 5 use bytes;
6 use fields ( 6 use fields (
7 'saxhandler', 7 'saxhandler',
8 'parser', 8 'parser',
9 9
10 'bound_jid', # undef until resource binding - then DJabberd::JI D object 10 'bound_jid', # undef until resource binding - then DJabberd::JI D object
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 return; 485 return;
486 } 486 }
487 487
488 # Net::SSLeays buffers internally, so if we didn't read anything, it's 488 # Net::SSLeays buffers internally, so if we didn't read anything, it's
489 # in its buffer 489 # in its buffer
490 unless ($data && length $data) { 490 unless ($data && length $data) {
491 # a few of these in a row implies an EOF. else it could 491 # a few of these in a row implies an EOF. else it could
492 # just be the underlying socket was readable, but there 492 # just be the underlying socket was readable, but there
493 # wasn't enough of an SSL packet for OpenSSL/etc to return 493 # wasn't enough of an SSL packet for OpenSSL/etc to return
494 # any unencrypted data back to us. 494 # any unencrypted data back to us.
495 if (++$self->{'ssl_empty_read_ct'} >= 10) { 495 # We call 'actual_error_on_empty_read' to avoid counting
496 # SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE as 'actual' errors
497 my $err = DJabberd::Stanza::StartTLS->actual_error_on_empty_read($ss l);
498 if($err && ++$self->{'ssl_empty_read_ct'} >= 10) {
499 $self->log->warn("SSL Read error: $err (assuming ssl_eof)");
496 $self->close('ssl_eof'); 500 $self->close('ssl_eof');
497 } 501 }
498 return; 502 return;
499 } 503 }
500 $self->{'ssl_empty_read_ct'} = 0; 504 $self->{'ssl_empty_read_ct'} = 0;
501 $bref = \$data; 505 $bref = \$data;
502 } else { 506 } else {
503 # non-ssl mode: 507 # non-ssl mode:
504 $bref = $self->read(20_000); 508 $bref = $self->read(20_000);
505 } 509 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 sub event_hup { my $self = shift; $self->close; } 798 sub event_hup { my $self = shift; $self->close; }
795 799
796 800
797 # Local Variables: 801 # Local Variables:
798 # mode: perl 802 # mode: perl
799 # c-basic-indent: 4 803 # c-basic-indent: 4
800 # indent-tabs-mode: nil 804 # indent-tabs-mode: nil
801 # End: 805 # End:
802 806
803 1; 807 1;
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r483