Mercurial > hg > nginx-vendor-current
comparison src/http/ngx_http_upstream_round_robin.c @ 330:5e3b425174f6 NGINX_0_6_9
nginx 0.6.9
*) Bugfix: a worker process may got caught in an endless loop, if the
HTTPS protocol was used; bug appeared in 0.6.7.
*) Bugfix: if server listened on two addresses or ports and trailing
wildcard was used, then nginx did not run.
*) Bugfix: the "ip_hash" directive might incorrectly mark servers as
down.
*) Bugfix: nginx could not be built on amd64; bug appeared in 0.6.8.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 28 Aug 2007 00:00:00 +0400 |
parents | 9fc4ab6673f9 |
children | 3a91bfeffaba |
comparison
equal
deleted
inserted
replaced
329:f2f8dc3e7933 | 330:5e3b425174f6 |
---|---|
301 | 301 |
302 if (pc->tries == rrp->peers->number) { | 302 if (pc->tries == rrp->peers->number) { |
303 | 303 |
304 /* it's a first try - get a current peer */ | 304 /* it's a first try - get a current peer */ |
305 | 305 |
306 i = pc->tries; | |
307 | |
306 for ( ;; ) { | 308 for ( ;; ) { |
307 rrp->current = ngx_http_upstream_get_peer(rrp->peers); | 309 rrp->current = ngx_http_upstream_get_peer(rrp->peers); |
308 | 310 |
309 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0, | 311 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
310 "get rr peer, current: %ui %i", | 312 "get rr peer, current: %ui %i", |
337 } | 339 } |
338 | 340 |
339 pc->tries--; | 341 pc->tries--; |
340 } | 342 } |
341 | 343 |
342 if (pc->tries) { | 344 if (pc->tries == 0) { |
343 continue; | 345 goto failed; |
344 } | 346 } |
345 | 347 |
346 goto failed; | 348 if (--i == 0) { |
349 ngx_log_error(NGX_LOG_ALERT, pc->log, 0, | |
350 "round robin upstream stuck on %ui tries", | |
351 pc->tries); | |
352 goto failed; | |
353 } | |
347 } | 354 } |
348 | 355 |
349 peer->current_weight--; | 356 peer->current_weight--; |
350 | 357 |
351 } else { | 358 } else { |
359 | |
360 i = pc->tries; | |
361 | |
352 for ( ;; ) { | 362 for ( ;; ) { |
353 n = rrp->current / (8 * sizeof(uintptr_t)); | 363 n = rrp->current / (8 * sizeof(uintptr_t)); |
354 m = (uintptr_t) 1 << rrp->current % (8 * sizeof(uintptr_t)); | 364 m = (uintptr_t) 1 << rrp->current % (8 * sizeof(uintptr_t)); |
355 | 365 |
356 if (!(rrp->tried[n] & m)) { | 366 if (!(rrp->tried[n] & m)) { |
383 | 393 |
384 if (rrp->current >= rrp->peers->number) { | 394 if (rrp->current >= rrp->peers->number) { |
385 rrp->current = 0; | 395 rrp->current = 0; |
386 } | 396 } |
387 | 397 |
388 if (pc->tries) { | 398 if (pc->tries == 0) { |
389 continue; | 399 goto failed; |
390 } | 400 } |
391 | 401 |
392 goto failed; | 402 if (--i == 0) { |
403 ngx_log_error(NGX_LOG_ALERT, pc->log, 0, | |
404 "round robin upstream stuck on %ui tries", | |
405 pc->tries); | |
406 goto failed; | |
407 } | |
393 } | 408 } |
394 | 409 |
395 peer->current_weight--; | 410 peer->current_weight--; |
396 } | 411 } |
397 | 412 |
498 return n; | 513 return n; |
499 } | 514 } |
500 | 515 |
501 for (i = 0; i < peers->number; i++) { | 516 for (i = 0; i < peers->number; i++) { |
502 if (peer[i].fails == 0) { | 517 if (peer[i].fails == 0) { |
503 peer[i].current_weight += peer[i].weight; | 518 peer[i].current_weight = peer[i].weight; |
504 | 519 |
505 } else { | 520 } else { |
506 /* 1 allows to go to quick recovery when all peers failed */ | 521 /* 1 allows to go to quick recovery when all peers failed */ |
507 peer[i].current_weight = 1; | 522 peer[i].current_weight = 1; |
508 } | 523 } |