From a7830cce6a3bf13996fe42503164437fb9809909 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 4 May 2009 01:34:01 +0000 Subject: Remove redundant socket closing/checking 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. --- lib/unicorn.rb | 9 +++------ 1 file 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 -- cgit v1.2.3-24-ge0c7