2013/9/8 headius (Charles Nutter) <headius / headius.com>:

> In JRuby, my first fix was to make IO.select aware of SSLSocket's native =
buffers by adding a method to query if SSLSocket had buffered data itself. =
This adds the socket to the list of pending read streams and does not attem=
pt to do a blocking select on it. This fixes the simple issue of sysread/sy=
sread_nonblock reading more data than requested and potentially draining th=
e stream and allows select to work correctly.

I think the right fix is that application uses read_nonblock before select.
See the document of IO#read_nonblock and OpenSSL::Buffering#read_nonblock.
I wrote this problem in [ruby-core:38681].

> However, the buffering issue is harder to fix. I believe buffering.rb nee=
ds to go away entirely, or at least needs to not buffer data on its own.

OpenSSL::Buffering#gets may be difficult to implement efficiently
without buffering.
--=20
Tanaka Akira