]> git.kaiwu.me - nginx.git/commitdiff
Upstream: fixed fail_timeout and max_fails > 1.
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 21 May 2013 17:47:50 +0000 (21:47 +0400)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 21 May 2013 17:47:50 +0000 (21:47 +0400)
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

src/http/modules/ngx_http_upstream_least_conn_module.c
src/http/ngx_http_upstream_round_robin.c

index 87c4d8d613b7bec53af063ae1ac362685dd83fea..dbef95d4164d3b6fb19717256ce5c8a4c7beeaa2 100644 (file)
@@ -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;
index d786ed14254bc6eeb11458ef8c32f101f8e61a9f..e0c6c58c7472baaf23a28c127fe627ebb8b668da 100644 (file)
@@ -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;
 }