comparison src/http/ngx_http_upstream.c @ 5994:5abf5af257a7

Upstream: avoid duplicate finalization. A request may be already finalized when ngx_http_upstream_finalize_request() is called, due to filter finalization: after filter finalization upstream can be finalized via ngx_http_upstream_cleanup(), either from ngx_http_terminate_request(), or because a new request was initiated to an upstream. Then the upstream code will see an error returned from the filter chain and will call the ngx_http_upstream_finalize_request() function again. To prevent corruption of various upstream data in this situation, make sure to do nothing but merely call ngx_http_finalize_request(). Prodded by Yichun Zhang, for details see the thread at http://nginx.org/pipermail/nginx-devel/2015-February/006539.html.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 02 Mar 2015 21:44:32 +0300
parents 174512857ccf
children 5f179f344096
comparison
equal deleted inserted replaced
5993:5b549cc7f698 5994:5abf5af257a7
3749 ngx_time_t *tp; 3749 ngx_time_t *tp;
3750 3750
3751 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 3751 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
3752 "finalize http upstream request: %i", rc); 3752 "finalize http upstream request: %i", rc);
3753 3753
3754 if (u->cleanup) { 3754 if (u->cleanup == NULL) {
3755 *u->cleanup = NULL; 3755 /* the request was already finalized */
3756 u->cleanup = NULL; 3756 ngx_http_finalize_request(r, NGX_DONE);
3757 } 3757 return;
3758 }
3759
3760 *u->cleanup = NULL;
3761 u->cleanup = NULL;
3758 3762
3759 if (u->resolved && u->resolved->ctx) { 3763 if (u->resolved && u->resolved->ctx) {
3760 ngx_resolve_name_done(u->resolved->ctx); 3764 ngx_resolve_name_done(u->resolved->ctx);
3761 u->resolved->ctx = NULL; 3765 u->resolved->ctx = NULL;
3762 } 3766 }