Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #1214 Puma >= 3.6.1 + SSL + Persistent Connections. Puma Hangs :( #1334

Merged
merged 1 commit into from Jun 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 18 additions & 25 deletions lib/puma/minissl.rb
Expand Up @@ -81,33 +81,26 @@ def flush
@socket.flush
end

def close
begin
# Try to setup (so that we can then close them) any
# partially initialized sockets.
while @engine.init?
# Don't let this socket hold this loop forever.
# If it can't send more packets within 1s, then
# 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)
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

@engine.inject notify
done = @engine.shutdown
def should_drop_bytes?
@engine.init? || !@engine.shutdown
end

break if done
def close
begin
# Read any drop any partially initialized sockets and any received bytes during shutdown.
# Don't let this socket hold this loop forever.
# If it can't send more packets within 1s, then give up.
while should_drop_bytes?
return if read_and_drop(1) == :timeout
end
rescue IOError, SystemCallError
# nothing
Expand Down