diff src/http/ngx_http_upstream_round_robin.c @ 400:6ebbca3d5ed7 NGINX_0_7_12

nginx 0.7.12 *) Feature: the "server_name" directive supports empty name "". *) Feature: the "gzip_disable" directive supports special "msie6" mask. *) Bugfix: if the "max_fails=0" parameter was used in upstream with several servers, then a worker process exited on a SIGFPE signal. Thanks to Maxim Dounin. *) Bugfix: a request body was dropped while redirection via an "error_page" directive. *) Bugfix: a full response was returned for request method HEAD while redirection via an "error_page" directive. *) Bugfix: the $r->header_in() method did not return value of the "Host", "User-Agent", and "Connection" request header lines; the bug had appeared in 0.7.0.
author Igor Sysoev <http://sysoev.ru>
date Tue, 26 Aug 2008 00:00:00 +0400
parents 984bb0b1399b
children 49a0eb7ce20c
line wrap: on
line diff
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -281,14 +281,14 @@ ngx_http_upstream_create_round_robin_pee
 
     for (i = 0; i < ur->naddrs; i++) {
 
-        len = INET_ADDRSTRLEN - 1 + 1 + sizeof(":65536") - 1;
+        len = NGX_INET_ADDRSTRLEN + sizeof(":65536") - 1;
 
         p = ngx_pnalloc(r->pool, len);
         if (p == NULL) {
             return NGX_ERROR;
         }
 
-        len = ngx_inet_ntop(AF_INET, &ur->addrs[i], p, INET_ADDRSTRLEN);
+        len = ngx_inet_ntop(AF_INET, &ur->addrs[i], p, NGX_INET_ADDRSTRLEN);
         len = ngx_sprintf(&p[len], ":%d", ur->port) - p;
 
         sin = ngx_pcalloc(r->pool, sizeof(struct sockaddr_in));
@@ -645,7 +645,9 @@ ngx_http_upstream_free_round_robin_peer(
         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",