diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-03-20 01:24:26 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-03-20 01:24:26 -0700 |
commit | 508eac750a8c278f5a965e6f4ac0f8a90677f1a2 (patch) | |
tree | e105674078b46f6ae2037e22ef7713550d7564a4 | |
parent | 995ef7040ffc6f4bf822838746428e37ab0d2ee1 (diff) | |
download | unicorn-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.
-rw-r--r-- | lib/unicorn/http_response.rb | 2 |
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 |