diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2012-12-19 04:03:55 +0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-12-18 21:44:19 +0000 |
commit | 42bf1f6de55b82af46fd8255453036c6582b7f19 (patch) | |
tree | 8c5760c9c33d514376e3b553a177f0163be175a1 /lib/rainbows/event_machine | |
parent | f7f9c6b8470e54e25a17cd1a9517f5030e43fa66 (diff) | |
download | rainbows-42bf1f6de55b82af46fd8255453036c6582b7f19.tar.gz |
close_connection_after_writing only if not deferred, as in cool.io Deferred responses may buffer more data down the line, so keep the connection alive if we have a deferred response body. [ew: clear @deferred when we really want to quit, updated commit message] Acked-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'lib/rainbows/event_machine')
-rw-r--r-- | lib/rainbows/event_machine/client.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/rainbows/event_machine/client.rb b/lib/rainbows/event_machine/client.rb index fc0dfe3..f3c2070 100644 --- a/lib/rainbows/event_machine/client.rb +++ b/lib/rainbows/event_machine/client.rb @@ -28,7 +28,7 @@ class Rainbows::EventMachine::Client < EM::Connection def quit super - close_connection_after_writing + close_connection_after_writing if nil == @deferred end def app_call input @@ -48,6 +48,7 @@ class Rainbows::EventMachine::Client < EM::Connection def deferred_errback(orig_body) @deferred.errback do orig_body.close if orig_body.respond_to?(:close) + @deferred = nil quit end end @@ -103,7 +104,8 @@ class Rainbows::EventMachine::Client < EM::Connection def next! @deferred.close if @deferred.respond_to?(:close) - @hp.keepalive? ? receive_data(@deferred = nil) : quit + @deferred = nil + @hp.keepalive? ? receive_data(nil) : quit end def unbind |