Avoid spinning on OpenSSL reads

Previously, if some sender were generating data to read on an
OpenSSL connection as fast as we could process it, we could easily
wind up looping on an openssl do_read operation without ever
considering other sockets.

The difference between this and the original method in
consider_reading() is that it only loops for a single completed
*frame* instead of looping until fd is drained or an error condition
was triggered.

{Patch split out by nickm}
This commit is contained in:
Mark Ellzey 2011-11-17 11:59:41 -05:00 committed by Nick Mathewson
parent 96c562fa49
commit 2aa036fa04

View File

@ -766,10 +766,13 @@ consider_reading(struct bufferevent_openssl *bev_ssl)
if (bev_ssl->write_blocked_on_read)
return;
while ((n_to_read = bytes_to_read(bev_ssl)) != 0) {
r = do_read(bev_ssl, n_to_read);
if (r <= 0)
n_to_read = bytes_to_read(bev_ssl);
while (n_to_read) {
if (do_read(bev_ssl, n_to_read) <= 0)
break;
n_to_read = SSL_pending(bev_ssl->ssl);
}
if (!bev_ssl->underlying) {