commit | 93b61fad8059f106423ad5d2b6372d16de2e01dd | [log] [tgz] |
---|---|---|
author | Maxim Dounin <mdounin@mdounin.ru> | Tue May 21 21:47:50 2013 +0400 |
committer | Maxim Dounin <mdounin@mdounin.ru> | Tue May 21 21:47:50 2013 +0400 |
tree | 4ecc4d527701f410f30b569984c7b52f1693fff2 | |
parent | 4ca32c31a0f842f2980c2d6a6584d6f680bfe839 [diff] |
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
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 87c4d8d..dbef95d 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 @@ } 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 d786ed1..e0c6c58 100644 --- a/src/http/ngx_http_upstream_round_robin.c +++ b/src/http/ngx_http_upstream_round_robin.c
@@ -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; }