mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
Upstream: fixed error handling of stale and revalidated cache send.
The NGX_DONE value returned from ngx_http_upstream_cache_send() indicates that upstream was already finalized in ngx_http_upstream_process_headers(). It was treated as a generic error which resulted in duplicate finalization. Handled NGX_HTTP_UPSTREAM_INVALID_HEADER from ngx_http_upstream_cache_send(). Previously, it could return within ngx_http_upstream_finalize_request(), and since it's below NGX_HTTP_SPECIAL_RESPONSE, a client connection could stuck.
This commit is contained in:
parent
0737e6d841
commit
661e40864f
@ -2404,9 +2404,20 @@ ngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
|
|
||||||
rc = u->reinit_request(r);
|
rc = u->reinit_request(r);
|
||||||
|
|
||||||
if (rc == NGX_OK) {
|
if (rc != NGX_OK) {
|
||||||
u->cache_status = NGX_HTTP_CACHE_STALE;
|
ngx_http_upstream_finalize_request(r, u, rc);
|
||||||
rc = ngx_http_upstream_cache_send(r, u);
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
u->cache_status = NGX_HTTP_CACHE_STALE;
|
||||||
|
rc = ngx_http_upstream_cache_send(r, u);
|
||||||
|
|
||||||
|
if (rc == NGX_DONE) {
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) {
|
||||||
|
rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_http_upstream_finalize_request(r, u, rc);
|
ngx_http_upstream_finalize_request(r, u, rc);
|
||||||
@ -2444,6 +2455,14 @@ ngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
u->cache_status = NGX_HTTP_CACHE_REVALIDATED;
|
u->cache_status = NGX_HTTP_CACHE_REVALIDATED;
|
||||||
rc = ngx_http_upstream_cache_send(r, u);
|
rc = ngx_http_upstream_cache_send(r, u);
|
||||||
|
|
||||||
|
if (rc == NGX_DONE) {
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) {
|
||||||
|
rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (valid == 0) {
|
if (valid == 0) {
|
||||||
valid = r->cache->valid_sec;
|
valid = r->cache->valid_sec;
|
||||||
updating = r->cache->updating_sec;
|
updating = r->cache->updating_sec;
|
||||||
@ -4150,9 +4169,20 @@ ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u,
|
|||||||
|
|
||||||
rc = u->reinit_request(r);
|
rc = u->reinit_request(r);
|
||||||
|
|
||||||
if (rc == NGX_OK) {
|
if (rc != NGX_OK) {
|
||||||
u->cache_status = NGX_HTTP_CACHE_STALE;
|
ngx_http_upstream_finalize_request(r, u, rc);
|
||||||
rc = ngx_http_upstream_cache_send(r, u);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u->cache_status = NGX_HTTP_CACHE_STALE;
|
||||||
|
rc = ngx_http_upstream_cache_send(r, u);
|
||||||
|
|
||||||
|
if (rc == NGX_DONE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) {
|
||||||
|
rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_http_upstream_finalize_request(r, u, rc);
|
ngx_http_upstream_finalize_request(r, u, rc);
|
||||||
|
Loading…
Reference in New Issue
Block a user