mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Deal with unsupported sockopts. Fixes #1241
Seems that the ability to extract the TCP_INFO is a conditional capability, with it failing in some common situations. So if it works, great, but as soon as it stops working, disable it entirely.
This commit is contained in:
parent
5bac8d5971
commit
604885b1fe
1 changed files with 14 additions and 4 deletions
|
@ -78,6 +78,8 @@ module Puma
|
||||||
ENV['RACK_ENV'] ||= "development"
|
ENV['RACK_ENV'] ||= "development"
|
||||||
|
|
||||||
@mode = :http
|
@mode = :http
|
||||||
|
|
||||||
|
@precheck_closing = true
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :binder, :leak_stack_on_error
|
attr_accessor :binder, :leak_stack_on_error
|
||||||
|
@ -121,10 +123,18 @@ module Puma
|
||||||
|
|
||||||
def closed_socket?(socket)
|
def closed_socket?(socket)
|
||||||
return false unless socket.kind_of? TCPSocket
|
return false unless socket.kind_of? TCPSocket
|
||||||
tcp_info = socket.getsockopt(Socket::SOL_TCP, Socket::TCP_INFO)
|
return false unless @precheck_closing
|
||||||
state = tcp_info.unpack(UNPACK_TCP_STATE_FROM_TCP_INFO)[0]
|
|
||||||
# TIME_WAIT: 6, CLOSE: 7, CLOSE_WAIT: 8, LAST_ACK: 9, CLOSING: 11
|
begin
|
||||||
(state >= 6 && state <= 9) || state == 11
|
tcp_info = socket.getsockopt(Socket::SOL_TCP, Socket::TCP_INFO)
|
||||||
|
rescue IOError, SystemCallError
|
||||||
|
@precheck_closing = false
|
||||||
|
false
|
||||||
|
else
|
||||||
|
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
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
def cork_socket(socket)
|
def cork_socket(socket)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue