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

Delta Between Two Patch Sets: lib/DJabberd/Stanza/StartTLS.pm

Issue 2341: avoid ssl_eof error on SSL_WANT_READ and friends SVN Base: http://code.sixapart.com/svn/djabberd/trunk/DJabberd
Left Patch Set: Created 1 year, 4 months ago
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 package DJabberd::Stanza::StartTLS; 1 package DJabberd::Stanza::StartTLS;
2 use strict; 2 use strict;
3 use base qw(DJabberd::Stanza); 3 use base qw(DJabberd::Stanza);
4 use Net::SSLeay; 4 use Net::SSLeay;
5 5
6 Net::SSLeay::load_error_strings(); 6 Net::SSLeay::load_error_strings();
7 Net::SSLeay::SSLeay_add_ssl_algorithms(); 7 Net::SSLeay::SSLeay_add_ssl_algorithms();
8 Net::SSLeay::randomize(); 8 Net::SSLeay::randomize();
9 9
10 use constant SSL_ERROR_WANT_READ => 2; 10 use constant SSL_ERROR_WANT_READ => 2;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 warn "SSL accept error on $conn\n"; 62 warn "SSL accept error on $conn\n";
63 $conn->close; 63 $conn->close;
64 return; 64 return;
65 } 65 }
66 66
67 warn "$conn: Cipher `" . Net::SSLeay::get_cipher($ssl) . "'\n"; 67 warn "$conn: Cipher `" . Net::SSLeay::get_cipher($ssl) . "'\n";
68 68
69 $conn->set_writer_func(DJabberd::Stanza::StartTLS->danga_socket_writerfunc($ conn)); 69 $conn->set_writer_func(DJabberd::Stanza::StartTLS->danga_socket_writerfunc($ conn));
70 } 70 }
71 71
72 sub should_we_close_on_zero_bytes { 72 sub actual_error_on_empty_read {
73 my ($class, $ssl) = @_; 73 my ($class, $ssl) = @_;
74 my $err = Net::SSLeay::get_error($ssl,-1); 74 my $err = Net::SSLeay::get_error($ssl, -1);
bradfitz 2008/06/19 20:45:39 space after comma
Jacob 2008/06/23 18:48:27 On 2008/06/19 20:45:39, bradfitz wrote: > space af
75 if ($err == SSL_ERROR_WANT_READ || 75 if ($err == SSL_ERROR_WANT_READ ||
76 $err == SSL_ERROR_WANT_WRITE || 76 $err == SSL_ERROR_WANT_WRITE ||
77 $err == SSL_ERROR_WANT_CONNECT || 77 $err == SSL_ERROR_WANT_CONNECT ||
78 $err == SSL_ERROR_WANT_ACCEPT) { 78 $err == SSL_ERROR_WANT_ACCEPT) {
79 # No, don't close on zero bytes, SSL is busy doing something like renego tiating encryption 79 # Not an actual error, SSL is busy doing something like renegotiating en cryption
80 # just try again next time 80 # just try again next time
81 return 0; 81 return 0;
82 } 82 }
83 # Yes, close on zero bytes 83 # This is actually an error (return the SSL err code)
84 # this is an SSL err code unlike the 'no-op' WANT_READ and WANT_WRITE 84 # unlike the 'no-op' WANT_READ and WANT_WRITE
85 return $err; 85 return $err;
bradfitz 2008/06/19 20:45:39 Does this function return a boolean or an error co
Jacob 2008/06/23 18:48:27 On 2008/06/19 20:45:39, bradfitz wrote: > Does thi
86 } 86 }
87 87
88 88
89 sub danga_socket_writerfunc { 89 sub danga_socket_writerfunc {
90 my ($class, $conn) = @_; 90 my ($class, $conn) = @_;
91 my $ssl = $conn->{ssl}; 91 my $ssl = $conn->{ssl};
92 return sub { 92 return sub {
93 my ($bref, $to_write, $offset) = @_; 93 my ($bref, $to_write, $offset) = @_;
94 94
95 # unless our event_read has been called, we don't want to try 95 # unless our event_read has been called, we don't want to try
(...skipping 30 matching lines...) Expand all
126 return 0; 126 return 0;
127 } 127 }
128 128
129 return $written; 129 return $written;
130 }; 130 };
131 } 131 }
132 132
133 1; 133 1;
134 134
135 # LocalWords: conn 135 # LocalWords: conn
LEFTRIGHT

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