mirror of
https://github.com/nginx/nginx.git
synced 2025-06-19 02:40:49 +08:00
Upstream: cached connections now tested against next_upstream.
Much like normal connections, cached connections are now tested against u->conf->next_upstream, and u->state->status is now always set. This allows to disable additional tries even with upstream keepalive by using "proxy_next_upstream off".
This commit is contained in:
parent
f5fff1eda0
commit
5a76856dc2
@ -3947,16 +3947,11 @@ ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u,
|
||||
"upstream timed out");
|
||||
}
|
||||
|
||||
if (u->peer.cached && ft_type == NGX_HTTP_UPSTREAM_FT_ERROR
|
||||
&& (!u->request_sent || !r->request_body_no_buffering))
|
||||
{
|
||||
status = 0;
|
||||
|
||||
if (u->peer.cached && ft_type == NGX_HTTP_UPSTREAM_FT_ERROR) {
|
||||
/* TODO: inform balancer instead */
|
||||
|
||||
u->peer.tries++;
|
||||
}
|
||||
|
||||
} else {
|
||||
switch (ft_type) {
|
||||
|
||||
case NGX_HTTP_UPSTREAM_FT_TIMEOUT:
|
||||
@ -3983,7 +3978,6 @@ ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u,
|
||||
default:
|
||||
status = NGX_HTTP_BAD_GATEWAY;
|
||||
}
|
||||
}
|
||||
|
||||
if (r->connection->error) {
|
||||
ngx_http_upstream_finalize_request(r, u,
|
||||
@ -3991,8 +3985,8 @@ ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u,
|
||||
return;
|
||||
}
|
||||
|
||||
if (status) {
|
||||
u->state->status = status;
|
||||
|
||||
timeout = u->conf->next_upstream_timeout;
|
||||
|
||||
if (u->peer.tries == 0
|
||||
@ -4022,7 +4016,6 @@ ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u,
|
||||
ngx_http_upstream_finalize_request(r, u, status);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (u->peer.connection) {
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
|
Loading…
Reference in New Issue
Block a user