libevent/libevent — pull request #2 by haseebq (2011-12-19 22:40:20+00:00)
Title: Make sure filtered openssl connections properly drain the underlying BE

I was investigating an issue with filtered openssl buffer events. The bufferevent stopped processing / pumping SSL data event when there was data available in the underlying BE. This is a regression in 2.0.16 and I believe the follow commit might have caused it:https://github.com/libevent/libevent/commit/2aa036fa0403977fa51812e711a1d5040c9fb5c9

Nick's suggestion of logging the number of bytes left in the underlying BE to see whether there was data available showed SSL_pending() ends up returning 0 in some cases even when the underlying BE's input buffer has data left to consume. To fix this, we now check if there is an underlying BE, and if there is, we drain it fully instead of relying on SSL_pending()