On Mon, Nov 05, 2012 at 10:18:28PM -0800, agentzh wrote:
> Hello!
>
> smallfish and I both ran into a small issue with the
> ngx_http_upstream_test_connect which does not catch errors like
> "Connection refused" when kqueue is used.
>
> The current logic only checks c->write->pending_eof but this error
> actually produced a read event on (at least) both Mac OS X and
> FreeBSD.
>
> I've attached a simple patch (for nginx 1.2.4) to fix this by checking
> both the read and write events.
>
> To reproduce the issue, please consider the following Nginx
> configuration snippet (assuming nothing is listening on the local port
> 1234):
>
> location = /t {
> proxy_pass http://127.0.0.1:1234/;
> }
>
> Accessing /t gives the following message in error.log:
>
> [error] 28474#0: *1 kevent() reported about an closed connection
> (61: Connection refused) while reading response header from upstream
>
> We can see that ngx_http_upstream missed it in
> ngx_http_upstream_test_connect but caught it when reading the
> (upstream) response header.
>
> After applying my patch, Nginx can now catch it in the context of connecting:
>
> [error] 34067#0: *1 kevent() reported that connect() failed (61:
> Connection refused) while connecting to upstream
>
> Best regards,
> -agentzh
Your patch looks good.
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel