diff options
author | Eric Wong <e@80x24.org> | 2016-05-09 22:10:20 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-05-09 22:10:20 +0000 |
commit | 6ba65a74eba96a769fad7a41a658a8c2418a8e29 (patch) | |
tree | 4091f402eeb114562ca81cdc637fb6b38a68d537 | |
parent | 88eea6156c45e9a24566c480270081c5a84d6ad3 (diff) | |
download | yahns-6ba65a74eba96a769fad7a41a658a8c2418a8e29.tar.gz |
We need to set state as early as possible as any modification of our HttpClient object is unsafe after it is handed over to the underlying application. Otherwise, we could be clobbering a state set inside the hijack but before we hit the case statement in HttpClient#step_write. This bug should not affect current (known) uses of rack.hijack; but will be necessary for upcoming proxy_pass to support unbuffered proxy responses.
-rw-r--r-- | lib/yahns/http_client.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb index 272db85..1d64e08 100644 --- a/lib/yahns/http_client.rb +++ b/lib/yahns/http_client.rb @@ -22,8 +22,7 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc: case rv = @state.wbuf_flush(self) when :wait_writable, :wait_readable return rv # tell epoll/kqueue to wait on this more - when :ignore # :ignore on hijack - @state = :ignore + when :ignore # :ignore on hijack, @state already set in hijack_cleanup return :ignore when Yahns::StreamFile @state = rv # continue looping @@ -254,8 +253,9 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc: # (and complicated) as our hijack support will allow "un-hijacking" # the socket. def hijack_cleanup - # prevent socket from holding process up + # prevent socket from holding process exit up Thread.current[:yahns_fdmap].forget(self) + @state = :ignore @input = nil # keep env["rack.input"] accessible, though end |