diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2013-05-21 21:47:50 +0400 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2013-05-21 21:47:50 +0400 |
commit | a1ab0dde4a34494214b0ad77f3a84bb18e72e08e (patch) | |
tree | 1a9693a293db52b939d458515cbea8a82e032605 /src | |
parent | 2b1779b9162541286c4d046411d4050d95a05ee8 (diff) | |
download | nginx-a1ab0dde4a34494214b0ad77f3a84bb18e72e08e.tar.gz nginx-a1ab0dde4a34494214b0ad77f3a84bb18e72e08e.zip |
Upstream: fixed fail_timeout and max_fails > 1.
Due to peer->checked always set since rev. c90801720a0c (1.3.0)
by round-robin and least_conn balancers (ip_hash not affected),
the code in ngx_http_upstream_free_round_robin_peer() function
incorrectly reset peer->fails too often.
Reported by Dmitry Popov,
http://mailman.nginx.org/pipermail/nginx-devel/2013-May/003720.html
Diffstat (limited to 'src')
-rw-r--r-- | src/http/modules/ngx_http_upstream_least_conn_module.c | 5 | ||||
-rw-r--r-- | src/http/ngx_http_upstream_round_robin.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/http/modules/ngx_http_upstream_least_conn_module.c b/src/http/modules/ngx_http_upstream_least_conn_module.c index 87c4d8d61..dbef95d41 100644 --- a/src/http/modules/ngx_http_upstream_least_conn_module.c +++ b/src/http/modules/ngx_http_upstream_least_conn_module.c @@ -282,7 +282,10 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data) } best->current_weight -= total; - best->checked = now; + + if (now - best->checked > best->fail_timeout) { + best->checked = now; + } pc->sockaddr = best->sockaddr; pc->socklen = best->socklen; diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c index d786ed142..e0c6c58c7 100644 --- a/src/http/ngx_http_upstream_round_robin.c +++ b/src/http/ngx_http_upstream_round_robin.c @@ -523,7 +523,10 @@ ngx_http_upstream_get_peer(ngx_http_upstream_rr_peer_data_t *rrp) rrp->tried[n] |= m; best->current_weight -= total; - best->checked = now; + + if (now - best->checked > best->fail_timeout) { + best->checked = now; + } return best; } |