diff options
author | Eric Wong <e@80x24.org> | 2017-03-23 00:03:57 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-03-23 00:03:57 +0000 |
commit | 079da35629a507719a7c15324cfba4e9c5a7be4d (patch) | |
tree | 67dabf7b0539f6cfd7faffd53dce6743177aaf2c /lib/unicorn/http_request.rb | |
parent | 703701aa9907df0c88d52873e47fabb15bb4a320 (diff) | |
parent | 19f969d961c0ff6f6f45b4231d859605530d71ab (diff) | |
download | unicorn-079da35629a507719a7c15324cfba4e9c5a7be4d.tar.gz |
* ccc-tcp-v3: test_ccc: use a pipe to synchronize test http_request: support proposed Raindrops::TCP states on non-Linux
Diffstat (limited to 'lib/unicorn/http_request.rb')
-rw-r--r-- | lib/unicorn/http_request.rb | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb index 9010007..7253497 100644 --- a/lib/unicorn/http_request.rb +++ b/lib/unicorn/http_request.rb @@ -105,7 +105,7 @@ class Unicorn::HttpParser env.include?('rack.hijack_io'.freeze) end - if defined?(Raindrops::TCP_Info) + if Raindrops.const_defined?(:TCP_Info) TCPI = Raindrops::TCP_Info.allocate def check_client_connection(socket) # :nodoc: @@ -118,14 +118,34 @@ class Unicorn::HttpParser end end - def closed_state?(state) # :nodoc: - case state - when 1 # ESTABLISHED - false - when 8, 6, 7, 9, 11 # CLOSE_WAIT, TIME_WAIT, CLOSE, LAST_ACK, CLOSING - true - else - false + if Raindrops.const_defined?(:TCP) + # raindrops 0.18.0+ supports FreeBSD + Linux using the same names + # Evaluate these hash lookups at load time so we can + # generate an opt_case_dispatch instruction + eval <<-EOS + def closed_state?(state) # :nodoc: + case state + when #{Raindrops::TCP[:ESTABLISHED]} + false + when #{Raindrops::TCP.values_at( + :CLOSE_WAIT, :TIME_WAIT, :CLOSE, :LAST_ACK, :CLOSING).join(',')} + true + else + false + end + end + EOS + else + # raindrops before 0.18 only supported TCP_INFO under Linux + def closed_state?(state) # :nodoc: + case state + when 1 # ESTABLISHED + false + when 8, 6, 7, 9, 11 # CLOSE_WAIT, TIME_WAIT, CLOSE, LAST_ACK, CLOSING + true + else + false + end end end else |