[PATCH] Nullify pc->connection in case of failure

Maxim Dounin mdounin at mdounin.ru
Thu Jan 19 15:46:55 UTC 2012


Hello!

On Thu, Jan 19, 2012 at 07:40:57AM +0100, Piotr Sikora wrote:

> Hi,
> attached patch fixes issue when nginx would try to close the same
> socket twice in case of failure to add events on new upstream
> connection (first time in ngx_event_connect_peer() and then again in
> ngx_http_upstream_finalize_request()).
> 
> Best regards,
> Piotr Sikora < piotr.sikora at frickle.com >
> 
> 
> --- src/event/ngx_event_connect.c.orig  Wed Nov 25 18:03:59 2009
> +++ src/event/ngx_event_connect.c       Thu Jan 19 06:29:09 2012
> @@ -247,6 +247,8 @@ failed:
>                       ngx_close_socket_n " failed");
>     }
> 
> +    pc->connection = NULL;
> +
>     return NGX_ERROR;
> }

I tend to think this patch isn't enough, as it might not del 
events already added as a result.

Probably better solution would be to just return NGX_ERROR if 
we've already set pc->connection, and let real 
ngx_close_connection() to do the work.

Maxim Dounin



More information about the nginx-devel mailing list