Skip to content

Commit f525ef6

Browse files
authored
preventing hang when io readable, but no app-data
TCPSocket may be readable due to handshake data arriving (NewSessionTicket's may arrive unprompted) - this essentially calls a SSL_read to process handshake data and returns nil when an actual EOFError has been raised, otherwise just returns (probably the symbol :wait_readable)
1 parent aeea49a commit f525ef6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/net/http.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,10 +2462,13 @@ def begin_transport(req)
24622462
debug 'Conn close because of keep_alive_timeout'
24632463
@socket.close
24642464
connect
2465-
elsif @socket.io.to_io.wait_readable(0) && @socket.eof?
2466-
debug "Conn close because of EOF"
2467-
@socket.close
2468-
connect
2465+
end
2466+
while @socket.io.to_io.wait_readable(0)
2467+
if @socket.io.to_io.read_nonblock(1, exception: false) == nil
2468+
debug "Conn close because of EOF"
2469+
@socket.close
2470+
connect
2471+
end
24692472
end
24702473
end
24712474

0 commit comments

Comments
 (0)