Feature #11044 ยป 0001-lib-net-protocol.rb-rbuf_fill-avoid-exception-with-r.patch
lib/net/protocol.rb | ||
---|---|---|
BUFSIZE = 1024 * 16
|
||
def rbuf_fill
|
||
begin
|
||
@rbuf << @io.read_nonblock(BUFSIZE)
|
||
rescue IO::WaitReadable
|
||
if IO.select([@io], nil, nil, @read_timeout)
|
||
retry
|
||
else
|
||
raise Net::ReadTimeout
|
||
end
|
||
rescue IO::WaitWritable
|
||
case rv = @io.read_nonblock(BUFSIZE, exception: false)
|
||
when String
|
||
return @rbuf << rv
|
||
when :wait_readable
|
||
IO.select([@io], nil, nil, @read_timeout) or raise Net::ReadTimeout
|
||
# continue looping
|
||
when :wait_writable
|
||
# OpenSSL::Buffering#read_nonblock may fail with IO::WaitWritable.
|
||
# http://www.openssl.org/support/faq.html#PROG10
|
||
if IO.select(nil, [@io], nil, @read_timeout)
|
||
retry
|
||
else
|
||
raise Net::ReadTimeout
|
||
end
|
||
end
|
||
IO.select(nil, [@io], nil, @read_timeout) or raise Net::ReadTimeout
|
||
# continue looping
|
||
when nil
|
||
# callers do not care about backtrace, so avoid allocating for it
|
||
raise EOFError, 'end of file reached', []
|
||
end while true
|
||
end
|
||
def rbuf_consume(len)
|
||
-
|