app error: Socket is not connected (Errno::ENOTCONN)

Eric Wong normalperson at yhbt.net
Fri Apr 27 18:59:40 UTC 2012


Joel Nimety <jnimety at continuity.net> wrote:
> I'm getting the following errors multiple times per request when using
> 4.3.0.  I do not receive any errors when using 4.2.1.  Please CC me on
> replies, I'm not subscribed to the mailing list.

Multiple times per request?  Yikes.  This can be expected occasionally.

The below patch will just silently ignore them since they're not
errors we can avoid/deal with any other way.  I'd still prefer
exceptions to not get raised at all (they're expensive).

Are the rest of you guys getting these errors intermittently, or only
once in a while.

Rainbows! has long had a similar patch as below, but I'm a bit concerned
as to why Joel is getting this multiple times per request...

>From 04901da5ae0b4655c83be05d24ae737f1b572002 Mon Sep 17 00:00:00 2001
From: Eric Wong <normalperson at yhbt.net>
Date: Fri, 27 Apr 2012 11:48:16 -0700
Subject: [PATCH] http_server: ignore ENOTCONN (mostly from shutdown(2))

Since there's nothing unicorn can do to avoid this error
on unconnected/halfway-connected clients, ignoring ENOTCONN
is a safe bet.

Rainbows! has long had this rescue as it called getpeername(2)
on untrusted sockets
---
 lib/unicorn/http_server.rb |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb
index f942e2f..14a6f9a 100644
--- a/lib/unicorn/http_server.rb
+++ b/lib/unicorn/http_server.rb
@@ -507,7 +507,8 @@ class Unicorn::HttpServer
   # the socket is closed at the end of this function
   def handle_error(client, e)
     msg = case e
-    when EOFError,Errno::ECONNRESET,Errno::EPIPE,Errno::EINVAL,Errno::EBADF
+    when EOFError,Errno::ECONNRESET,Errno::EPIPE,Errno::EINVAL,Errno::EBADF,
+         Errno::ENOTCONN
       Unicorn::Const::ERROR_500_RESPONSE
     when Unicorn::RequestURITooLongError
       Unicorn::Const::ERROR_414_RESPONSE
-- 
Eric Wong


More information about the mongrel-unicorn mailing list