mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
fix #1214 Puma >= 3.6.1 + SSL + Persistent Connections. Puma Hangs :(
This commit is contained in:
parent
604885b1fe
commit
4238235760
1 changed files with 18 additions and 25 deletions
|
@ -81,33 +81,26 @@ module Puma
|
||||||
@socket.flush
|
@socket.flush
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def read_and_drop(timeout = 1)
|
||||||
|
return :timeout unless IO.select([@socket], nil, nil, timeout)
|
||||||
|
read_nonblock(1024)
|
||||||
|
:drop
|
||||||
|
rescue Errno::EAGAIN
|
||||||
|
# do nothing
|
||||||
|
:eagain
|
||||||
|
end
|
||||||
|
|
||||||
|
def should_drop_bytes?
|
||||||
|
@engine.init? || !@engine.shutdown
|
||||||
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
begin
|
begin
|
||||||
# Try to setup (so that we can then close them) any
|
# Read any drop any partially initialized sockets and any received bytes during shutdown.
|
||||||
# partially initialized sockets.
|
# Don't let this socket hold this loop forever.
|
||||||
while @engine.init?
|
# If it can't send more packets within 1s, then give up.
|
||||||
# Don't let this socket hold this loop forever.
|
while should_drop_bytes?
|
||||||
# If it can't send more packets within 1s, then
|
return if read_and_drop(1) == :timeout
|
||||||
# give up.
|
|
||||||
return unless IO.select([@socket], nil, nil, 1)
|
|
||||||
begin
|
|
||||||
read_nonblock(1024)
|
|
||||||
rescue Errno::EAGAIN
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
done = @engine.shutdown
|
|
||||||
|
|
||||||
while true
|
|
||||||
enc = @engine.extract
|
|
||||||
@socket.write enc
|
|
||||||
|
|
||||||
notify = @socket.sysread(1024)
|
|
||||||
|
|
||||||
@engine.inject notify
|
|
||||||
done = @engine.shutdown
|
|
||||||
|
|
||||||
break if done
|
|
||||||
end
|
end
|
||||||
rescue IOError, SystemCallError
|
rescue IOError, SystemCallError
|
||||||
# nothing
|
# nothing
|
||||||
|
|
Loading…
Reference in a new issue