about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-05-04 01:34:01 +0000
committerEric Wong <normalperson@yhbt.net>2009-05-04 03:49:55 +0000
commita7830cce6a3bf13996fe42503164437fb9809909 (patch)
tree9dcc662f83d4816de0e32fb12595685067dfb3ee
parent9af6edf6af212c1fcaccb1999b66dfd89ccfb693 (diff)
downloadunicorn-a7830cce6a3bf13996fe42503164437fb9809909.tar.gz
If our response succeeds, we've already closed the socket.
Otherwise, we would've raised an exception at some point hit one
of the rescue clauses.
-rw-r--r--lib/unicorn.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 593b43b..db25223 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -420,19 +420,16 @@ module Unicorn
     # the socket is closed at the end of this function
     rescue EOFError,Errno::ECONNRESET,Errno::EPIPE,Errno::EINVAL,Errno::EBADF
       client.write_nonblock(Const::ERROR_500_RESPONSE) rescue nil
+      client.close rescue nil
     rescue HttpParserError # try to tell the client they're bad
       client.write_nonblock(Const::ERROR_400_RESPONSE) rescue nil
+      client.close rescue nil
     rescue Object => e
       client.write_nonblock(Const::ERROR_500_RESPONSE) rescue nil
+      client.close rescue nil
       logger.error "Read error: #{e.inspect}"
       logger.error e.backtrace.join("\n")
     ensure
-      begin
-        client.closed? or client.close
-      rescue Object => e
-        logger.error "Client error: #{e.inspect}"
-        logger.error e.backtrace.join("\n")
-      end
       @request.reset
     end