From 508eac750a8c278f5a965e6f4ac0f8a90677f1a2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 20 Mar 2009 01:24:26 -0700 Subject: HttpResponse: close body if it can close 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. --- lib/unicorn/http_response.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') 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 -- cgit v1.2.3-24-ge0c7