Mercurial > hg > nginx-vendor-0-7
diff src/event/ngx_event_connect.c @ 212:56688ed172c8 NGINX_0_3_53
nginx 0.3.53
*) Change: the "add_header" directive adds the string to 204, 301, and
302 responses.
*) Feature: the "server" directive in the "upstream" context supports
the "weight" parameter.
*) Feature: the "server_name" directive supports the "*" wildcard.
*) Feature: nginx supports the request body size more than 2G.
*) Bugfix: if a client was successfully authorized using "satisfy_any
on", then anyway the message "access forbidden by rule" was written
in the log.
*) Bugfix: the "PUT" method may erroneously not create a file and
return the 409 code.
*) Bugfix: if the IMAP/POP3 backend returned an error, then nginx
continued proxying anyway.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Fri, 07 Jul 2006 00:00:00 +0400 |
parents | 8759b346e431 |
children | 0effe91f6083 |
line wrap: on
line diff
--- a/src/event/ngx_event_connect.c +++ b/src/event/ngx_event_connect.c @@ -81,8 +81,6 @@ ngx_event_connect_peer(ngx_peer_connecti pc->peers->current = 0; } - pc->peers->weight = pc->peers->peer[pc->peers->current].weight; - pc->tries--; if (pc->tries) { @@ -92,16 +90,16 @@ ngx_event_connect_peer(ngx_peer_connecti goto failed; } - pc->peers->weight--; + peer->current_weight--; - if (pc->peers->weight == 0) { + if (peer->current_weight == 0) { + peer->current_weight = peer->weight; + pc->peers->current++; if (pc->peers->current >= pc->peers->number) { pc->peers->current = 0; } - - pc->peers->weight = pc->peers->peer[pc->peers->current].weight; } } else { @@ -131,6 +129,20 @@ ngx_event_connect_peer(ngx_peer_connecti goto failed; } + + peer->current_weight--; + + if (peer->current_weight == 0) { + peer->current_weight = peer->weight; + + if (pc->cur_peer == pc->peers->current) { + pc->peers->current++; + + if (pc->peers->current >= pc->peers->number) { + pc->peers->current = 0; + } + } + } } } @@ -358,15 +370,22 @@ failed: void ngx_event_connect_peer_failed(ngx_peer_connection_t *pc, ngx_uint_t down) { - time_t now; + time_t now; + ngx_peer_t *peer; if (down) { now = ngx_time(); /* ngx_lock_mutex(pc->peers->mutex); */ - pc->peers->peer[pc->cur_peer].fails++; - pc->peers->peer[pc->cur_peer].accessed = now; + peer = &pc->peers->peer[pc->cur_peer]; + + peer->fails++; + peer->accessed = now; + + if (peer->current_weight > 1) { + peer->current_weight /= 2; + } /* ngx_unlock_mutex(pc->peers->mutex); */ }