about summary refs log tree commit homepage
path: root/lib/rainbows/event_machine/response_pipe.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rainbows/event_machine/response_pipe.rb')
-rw-r--r--lib/rainbows/event_machine/response_pipe.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/rainbows/event_machine/response_pipe.rb b/lib/rainbows/event_machine/response_pipe.rb
index 88d6e5a..7d4988a 100644
--- a/lib/rainbows/event_machine/response_pipe.rb
+++ b/lib/rainbows/event_machine/response_pipe.rb
@@ -5,8 +5,8 @@ module Rainbows::EventMachine::ResponsePipe
   # so a single buffer for all clients will work safely
   BUF = ''
 
-  def initialize(client, alive)
-    @client, @alive = client, alive
+  def initialize(client, alive, body)
+    @client, @alive, @body = client, alive, body
   end
 
   def notify_readable
@@ -23,6 +23,7 @@ module Rainbows::EventMachine::ResponsePipe
 
   def unbind
     @client.quit unless @alive
-    @io.close
+    @body.close if @body.respond_to?(:close)
+    @io.close unless @io.closed?
   end
 end