aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-08-24 15:58:13 +0000
committerIgor Sysoev <igor@sysoev.ru>2007-08-24 15:58:13 +0000
commit012f231bbc73b6b8462d52eefe7bfa9be5e8d35c (patch)
tree324f72afb83fadb8ce2373236756d6efff63b2d8 /src
parent97e9336753a4dd8a210be3ebaa7534a690c34152 (diff)
downloadnginx-012f231bbc73b6b8462d52eefe7bfa9be5e8d35c.tar.gz
nginx-012f231bbc73b6b8462d52eefe7bfa9be5e8d35c.zip
add guard code to prevent endless loop
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_upstream_round_robin.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index bdeeb16c8..2db99b2ac 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -303,6 +303,8 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
/* it's a first try - get a current peer */
+ i = pc->tries;
+
for ( ;; ) {
rrp->current = ngx_http_upstream_get_peer(rrp->peers);
@@ -339,16 +341,24 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
pc->tries--;
}
- if (pc->tries) {
- continue;
+ if (pc->tries == 0) {
+ goto failed;
}
- goto failed;
+ if (--i == 0) {
+ ngx_log_error(NGX_LOG_ALERT, pc->log, 0,
+ "round robin upstream stuck on %ui tries",
+ pc->tries);
+ goto failed;
+ }
}
peer->current_weight--;
} else {
+
+ i = pc->tries;
+
for ( ;; ) {
n = rrp->current / (8 * sizeof(uintptr_t));
m = (uintptr_t) 1 << rrp->current % (8 * sizeof(uintptr_t));
@@ -385,11 +395,16 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
rrp->current = 0;
}
- if (pc->tries) {
- continue;
+ if (pc->tries == 0) {
+ goto failed;
}
- goto failed;
+ if (--i == 0) {
+ ngx_log_error(NGX_LOG_ALERT, pc->log, 0,
+ "round robin upstream stuck on %ui tries",
+ pc->tries);
+ goto failed;
+ }
}
peer->current_weight--;