about summary refs log tree commit homepage
path: root/lib/rainbows/writer_thread_pool.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rainbows/writer_thread_pool.rb')
-rw-r--r--lib/rainbows/writer_thread_pool.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rainbows/writer_thread_pool.rb b/lib/rainbows/writer_thread_pool.rb
index 6896787..67c8e83 100644
--- a/lib/rainbows/writer_thread_pool.rb
+++ b/lib/rainbows/writer_thread_pool.rb
@@ -24,7 +24,13 @@ module Rainbows::WriterThreadPool
   @@q = nil
 
   def async_write_body(qclient, body, range)
-    qclient.q << [ qclient.to_io, :body, body, range ]
+    if body.respond_to?(:close)
+      Rainbows::SyncClose.new(body) do |body|
+        qclient.q << [ qclient.to_io, :body, body, range ]
+      end
+    else
+      qclient.q << [ qclient.to_io, :body, body, range ]
+    end
   end
 
   def process_client(client) # :nodoc: