]> git.kaiwu.me - nginx.git/commitdiff
fix divide by zero if max_fails=0
authorIgor Sysoev <igor@sysoev.ru>
Tue, 26 Aug 2008 14:34:16 +0000 (14:34 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 26 Aug 2008 14:34:16 +0000 (14:34 +0000)
src/http/ngx_http_upstream_round_robin.c

index d9450c95c2ff63c27c1a7557879c167a9fd869d2..2479baa7876b001a1dc3c8cbc7044d883a0fad43 100644 (file)
@@ -645,7 +645,9 @@ ngx_http_upstream_free_round_robin_peer(ngx_peer_connection_t *pc, void *data,
         peer->fails++;
         peer->accessed = now;
 
-        peer->current_weight -= peer->weight / peer->max_fails;
+        if (peer->max_fails) {
+            peer->current_weight -= peer->weight / peer->max_fails;
+        }
 
         ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
                        "free rr peer failed: %ui %i",