# HG changeset patch # User Maxim Dounin # Date 1353090559 0 # Node ID e62219793beb7f9d308ff6c366360aca153f8044 # Parent dcb853acae9750f0a804cdd193f6c2ce35e5da1c Upstream: better detection of connect() failures with kqueue. Pending EOF might be reported on both read and write events, whichever comes first, so check both of them. Patch by Yichun Zhang (agentzh), slightly modified. diff -r dcb853acae97 -r e62219793beb src/http/ngx_http_upstream.c --- a/src/http/ngx_http_upstream.c Fri Nov 16 12:18:05 2012 +0000 +++ b/src/http/ngx_http_upstream.c Fri Nov 16 18:29:19 2012 +0000 @@ -1809,9 +1809,16 @@ #if (NGX_HAVE_KQUEUE) if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { - if (c->write->pending_eof) { + if (c->write->pending_eof || c->read->pending_eof) { + if (c->write->pending_eof) { + err = c->write->kq_errno; + + } else { + err = c->read->kq_errno; + } + c->log->action = "connecting to upstream"; - (void) ngx_connection_error(c, c->write->kq_errno, + (void) ngx_connection_error(c, err, "kevent() reported that connect() failed"); return NGX_ERROR; }