diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-02-08 22:45:20 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-02-11 01:57:05 +0000 |
commit | e166cfe5e8d648b544b1291ec157bd234a425e21 (patch) | |
tree | 8ac56aadc51d81d4d250cfec696446f19ffd1d64 /lib/rainbows/stream_response_epoll/client.rb | |
parent | e6faf9e26bcb172026a4984ecadbaa8b6789bcb7 (diff) | |
download | rainbows-e166cfe5e8d648b544b1291ec157bd234a425e21.tar.gz |
This requires Rack 1.5.x and unicorn 4.6.0 for hijacking support. Older versions of Rack continue to work fine, but we must use unicorn 4.6.0 features to support this.
Diffstat (limited to 'lib/rainbows/stream_response_epoll/client.rb')
-rw-r--r-- | lib/rainbows/stream_response_epoll/client.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/rainbows/stream_response_epoll/client.rb b/lib/rainbows/stream_response_epoll/client.rb index db303b0..dc226d6 100644 --- a/lib/rainbows/stream_response_epoll/client.rb +++ b/lib/rainbows/stream_response_epoll/client.rb @@ -18,7 +18,7 @@ class Rainbows::StreamResponseEpoll::Client attr_reader :to_io def initialize(io, unwritten) - @closed = false + @finish = false @to_io = io @wr_queue = [ unwritten.dup ] EP.set(self, OUT) @@ -29,7 +29,11 @@ class Rainbows::StreamResponseEpoll::Client end def close - @closed = true + @finish = true + end + + def hijack(hijack) + @finish = hijack end def epoll_run @@ -49,10 +53,14 @@ class Rainbows::StreamResponseEpoll::Client end def on_write_complete - if @closed + if true == @finish @to_io.shutdown @to_io.close N.decr(0, 1) + elsif @finish.respond_to?(:call) # hijacked + EP.delete(self) + N.decr(0, 1) + @finish.call(@to_io) end end end |