mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Don't handle closed clients
This commit is contained in:
parent
dd51c3b409
commit
baccf80a09
1 changed files with 16 additions and 0 deletions
|
@ -100,6 +100,8 @@ module Puma
|
|||
# packetizes our stream. This improves both latency and throughput.
|
||||
#
|
||||
if RUBY_PLATFORM =~ /linux/
|
||||
UNPACK_TCP_STATE_FROM_TCP_INFO = "C".freeze
|
||||
|
||||
# 6 == Socket::IPPROTO_TCP
|
||||
# 3 == TCP_CORK
|
||||
# 1/0 == turn on/off
|
||||
|
@ -116,12 +118,24 @@ module Puma
|
|||
rescue IOError, SystemCallError
|
||||
end
|
||||
end
|
||||
|
||||
def closed_socket?(socket)
|
||||
return false unless socket.kind_of? TCPSocket
|
||||
tcp_info = socket.getsockopt(Socket::SOL_TCP, Socket::TCP_INFO)
|
||||
state = tcp_info.unpack(UNPACK_TCP_STATE_FROM_TCP_INFO)[0]
|
||||
# TIME_WAIT: 6, CLOSE: 7, CLOSE_WAIT: 8, LAST_ACK: 9, CLOSING: 11
|
||||
(state >= 6 && state <= 9) || state == 11
|
||||
end
|
||||
else
|
||||
def cork_socket(socket)
|
||||
end
|
||||
|
||||
def uncork_socket(socket)
|
||||
end
|
||||
|
||||
def closed_socket?(socket)
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def backlog
|
||||
|
@ -550,6 +564,8 @@ module Puma
|
|||
env = req.env
|
||||
client = req.io
|
||||
|
||||
return false if closed_socket?(client)
|
||||
|
||||
normalize_env env, req
|
||||
|
||||
env[PUMA_SOCKET] = client
|
||||
|
|
Loading…
Add table
Reference in a new issue