From 3495d59763e6159975debf32728dc53fc41c5ea1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 27 Dec 2010 20:25:39 -0800 Subject: several response body#close fixes Some middlewares require the Rack env to be preserved all the way through to close, so we'll ensure all request models preserve it. We also need to better response body wrappers/proxies always get fired properly when returning. IO.copy_stream and "sendfile" gem users could hit cases where wrappers did not fire properly. --- lib/rainbows/writer_thread_pool.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/rainbows/writer_thread_pool.rb') 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: -- cgit v1.2.3-24-ge0c7