Skip to content

Commit 5b4b812

Browse files
committed
Loop on filtering SSL reads until we are blocked or exhausted.
This is not a perfect fix, but it's much much better than the current buggy behavior, which could lead to filtering SSL connections that just stopped reading. Based on ideas by Maseeb Abdul Qadir and Mark Ellzey.
1 parent d84d917 commit 5b4b812

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

bufferevent_openssl.c

+17
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,23 @@ consider_reading(struct bufferevent_openssl *bev_ssl)
781781
* already been done, since OpenSSL went and read a
782782
* whole SSL record anyway. */
783783
n_to_read = SSL_pending(bev_ssl->ssl);
784+
785+
/* XXX This if statement is actually a bad bug, added to avoid
786+
* XXX a worse bug.
787+
*
788+
* The bad bug: It can potentially cause resource unfairness
789+
* by reading too much data from the underlying bufferevent;
790+
* it can potentially cause read looping if the underlying
791+
* bufferevent is a bufferevent_pair and deferred callbacks
792+
* aren't used.
793+
*
794+
* The worse bug: If we didn't do this, then we would
795+
* potentially not read any more from bev_ssl->underlying
796+
* until more data arrived there, which could lead to us
797+
* waiting forever.
798+
*/
799+
if (!n_to_read && bev_ssl->underlying)
800+
n_to_read = bytes_to_read(bev_ssl);
784801
}
785802

786803
if (!bev_ssl->underlying) {

0 commit comments

Comments
 (0)