summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2013-02-11 14:56:14 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2013-02-11 14:56:14 +0000
commitff145c057451bfe40b5d59c5873091df07964831 (patch)
tree66768fa4838f5b540f2f890f4f5b0655b1fcc982
parent6b070a4d216eb2083a96b3a3f24996f43940c4cd (diff)
downloadnginx-ff145c057451bfe40b5d59c5873091df07964831.tar.gz
Merge of r4992: off-by-one with 32/64 upstream backup servers.
Fixed off-by-one during upstream state resetting when switching to backup servers if there were exactly 32 (64 on 64-bit platforms) backup servers configured. Based on patch by Thomas Chen (ticket #257).
-rw-r--r--src/http/modules/ngx_http_upstream_least_conn_module.c4
-rw-r--r--src/http/ngx_http_upstream_round_robin.c4
2 files changed, 6 insertions, 2 deletions
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 21156ae1a..bd2f1bc9e 100644
--- a/src/http/modules/ngx_http_upstream_least_conn_module.c
+++ b/src/http/modules/ngx_http_upstream_least_conn_module.c
@@ -313,7 +313,9 @@ failed:
lcp->rrp.peers = peers->next;
pc->tries = lcp->rrp.peers->number;
- n = lcp->rrp.peers->number / (8 * sizeof(uintptr_t)) + 1;
+ n = (lcp->rrp.peers->number + (8 * sizeof(uintptr_t) - 1))
+ / (8 * sizeof(uintptr_t));
+
for (i = 0; i < n; i++) {
lcp->rrp.tried[i] = 0;
}
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index 4b78cffd8..61dce69cb 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -474,7 +474,9 @@ failed:
rrp->peers = peers->next;
pc->tries = rrp->peers->number;
- n = rrp->peers->number / (8 * sizeof(uintptr_t)) + 1;
+ n = (rrp->peers->number + (8 * sizeof(uintptr_t) - 1))
+ / (8 * sizeof(uintptr_t));
+
for (i = 0; i < n; i++) {
rrp->tried[i] = 0;
}