about summary refs log tree commit homepage
path: root/lib/unicorn/http_response.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-03-20 01:24:26 -0700
committerEric Wong <normalperson@yhbt.net>2009-03-20 01:24:26 -0700
commit508eac750a8c278f5a965e6f4ac0f8a90677f1a2 (patch)
treee105674078b46f6ae2037e22ef7713550d7564a4 /lib/unicorn/http_response.rb
parent995ef7040ffc6f4bf822838746428e37ab0d2ee1 (diff)
downloadunicorn-508eac750a8c278f5a965e6f4ac0f8a90677f1a2.tar.gz
The body could be an IO object that is closeable.
So make sure we close it if it can be closed to
avoid file descriptor leakage.
Diffstat (limited to 'lib/unicorn/http_response.rb')
-rw-r--r--lib/unicorn/http_response.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb
index 7bbb940..2635f14 100644
--- a/lib/unicorn/http_response.rb
+++ b/lib/unicorn/http_response.rb
@@ -50,6 +50,8 @@ module Unicorn
                    "Connection: close\r\n" \
                    "#{out.join("\r\n")}\r\n\r\n")
       body.each { |chunk| socket_write(socket, chunk) }
+      ensure
+        body.respond_to?(:close) and body.close rescue nil
     end
 
     private