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

Defer checking if socket is closed #2602

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 5 additions & 5 deletions lib/puma/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def handle_request(client, lines)
env = client.env
io = client.io # io may be a MiniSSL::Socket

return false if closed_socket?(io)

normalize_env env, client

env[PUMA_SOCKET] = io
Expand Down Expand Up @@ -161,10 +159,12 @@ def handle_request(client, lines)
fast_write io, CLOSE_CHUNKED
io.flush
end
rescue SystemCallError, IOError
rescue SystemCallError
raise ConnectionError, "Connection error detected during write"
end

rescue IOError
return false if closed_socket?
raise ConnectionError, "Socket timeout writing data"
ensure
uncork_socket io

Expand Down Expand Up @@ -205,7 +205,7 @@ def fast_write(io, str)
end

retry
rescue Errno::EPIPE, SystemCallError, IOError
rescue Errno::EPIPE, SystemCallError
raise ConnectionError, "Socket timeout writing data"
end

Expand Down