aboutsummaryrefslogtreecommitdiff
path: root/src/event/ngx_event_connect.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2006-07-07 16:33:19 +0000
committerIgor Sysoev <igor@sysoev.ru>2006-07-07 16:33:19 +0000
commit1765f475445a054994611d2053cc181fb3504615 (patch)
treea816e7cada7b3bec35e866ee9b22f78bda6c5af8 /src/event/ngx_event_connect.c
parentb798d507122449c1baa85b1de47eec31cc0487a6 (diff)
downloadnginx-release-0.3.53.tar.gz
nginx-release-0.3.53.zip
nginx-0.3.53-RELEASE importrelease-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.
Diffstat (limited to 'src/event/ngx_event_connect.c')
-rw-r--r--src/event/ngx_event_connect.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/event/ngx_event_connect.c b/src/event/ngx_event_connect.c
index 157c48002..2b4c08d05 100644
--- a/src/event/ngx_event_connect.c
+++ b/src/event/ngx_event_connect.c
@@ -81,8 +81,6 @@ ngx_event_connect_peer(ngx_peer_connection_t *pc)
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_connection_t *pc)
goto failed;
}
- pc->peers->weight--;
+ peer->current_weight--;
+
+ if (peer->current_weight == 0) {
+ peer->current_weight = peer->weight;
- if (pc->peers->weight == 0) {
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_connection_t *pc)
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); */
}