Mercurial > hg > nginx
changeset 5220:1d68b502088c
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
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 21 May 2013 21:47:50 +0400 |
parents | 32fe021911c9 |
children | 8f74cf107137 |
files | src/http/modules/ngx_http_upstream_least_conn_module.c src/http/ngx_http_upstream_round_robin.c |
diffstat | 2 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_upstream_least_conn_module.c Fri May 10 16:53:45 2013 +0200 +++ b/src/http/modules/ngx_http_upstream_least_conn_module.c Tue May 21 21:47:50 2013 +0400 @@ -282,7 +282,10 @@ } 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;
--- a/src/http/ngx_http_upstream_round_robin.c Fri May 10 16:53:45 2013 +0200 +++ b/src/http/ngx_http_upstream_round_robin.c Tue May 21 21:47:50 2013 +0400 @@ -523,7 +523,10 @@ rrp->tried[n] |= m; best->current_weight -= total; - best->checked = now; + + if (now - best->checked > best->fail_timeout) { + best->checked = now; + } return best; }