# HG changeset patch # User Maxim Dounin # Date 1392730240 -14400 # Node ID c8a14fbd3ce9f59a0157fb0d0dbe37ca382aaba6 # Parent 7a7c6104b47465b59bddcca9e3738af4986e5d84 Upstream: ngx_post_event() instead of upgraded call (ticket #503). If a request is finalized in the first call to the ngx_http_upstream_process_upgraded() function, e.g., because upstream server closed the connection for some reason, in the second call the u->peer.connection pointer will be null, resulting in segmentation fault. Fix is to avoid second direct call, and post event instead. This ensures that ngx_http_upstream_process_upgraded() won't be called again if a request is finalized. diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -2456,7 +2456,9 @@ ngx_http_upstream_upgrade(ngx_http_reque if (u->peer.connection->read->ready || u->buffer.pos != u->buffer.last) { + ngx_post_event(c->read, &ngx_posted_events); ngx_http_upstream_process_upgraded(r, 1, 1); + return; } ngx_http_upstream_process_upgraded(r, 0, 1);