Mercurial > hg > nginx-quic
comparison src/event/ngx_event_connect.c @ 663:6d5c1535bb9d release-0.3.53
nginx-0.3.53-RELEASE import
*) 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 <igor@sysoev.ru> |
---|---|
date | Fri, 07 Jul 2006 16:33:19 +0000 |
parents | 95d7da23ea53 |
children | 4d68c486fcb0 |
comparison
equal
deleted
inserted
replaced
662:4c15f63afe65 | 663:6d5c1535bb9d |
---|---|
79 | 79 |
80 if (pc->peers->current >= pc->peers->number) { | 80 if (pc->peers->current >= pc->peers->number) { |
81 pc->peers->current = 0; | 81 pc->peers->current = 0; |
82 } | 82 } |
83 | 83 |
84 pc->peers->weight = pc->peers->peer[pc->peers->current].weight; | |
85 | |
86 pc->tries--; | 84 pc->tries--; |
87 | 85 |
88 if (pc->tries) { | 86 if (pc->tries) { |
89 continue; | 87 continue; |
90 } | 88 } |
91 | 89 |
92 goto failed; | 90 goto failed; |
93 } | 91 } |
94 | 92 |
95 pc->peers->weight--; | 93 peer->current_weight--; |
96 | 94 |
97 if (pc->peers->weight == 0) { | 95 if (peer->current_weight == 0) { |
96 peer->current_weight = peer->weight; | |
97 | |
98 pc->peers->current++; | 98 pc->peers->current++; |
99 | 99 |
100 if (pc->peers->current >= pc->peers->number) { | 100 if (pc->peers->current >= pc->peers->number) { |
101 pc->peers->current = 0; | 101 pc->peers->current = 0; |
102 } | 102 } |
103 | |
104 pc->peers->weight = pc->peers->peer[pc->peers->current].weight; | |
105 } | 103 } |
106 | 104 |
107 } else { | 105 } else { |
108 for ( ;; ) { | 106 for ( ;; ) { |
109 peer = &pc->peers->peer[pc->cur_peer]; | 107 peer = &pc->peers->peer[pc->cur_peer]; |
128 if (pc->tries) { | 126 if (pc->tries) { |
129 continue; | 127 continue; |
130 } | 128 } |
131 | 129 |
132 goto failed; | 130 goto failed; |
131 } | |
132 | |
133 peer->current_weight--; | |
134 | |
135 if (peer->current_weight == 0) { | |
136 peer->current_weight = peer->weight; | |
137 | |
138 if (pc->cur_peer == pc->peers->current) { | |
139 pc->peers->current++; | |
140 | |
141 if (pc->peers->current >= pc->peers->number) { | |
142 pc->peers->current = 0; | |
143 } | |
144 } | |
133 } | 145 } |
134 } | 146 } |
135 } | 147 } |
136 | 148 |
137 /* ngx_unlock_mutex(pc->peers->mutex); */ | 149 /* ngx_unlock_mutex(pc->peers->mutex); */ |
356 | 368 |
357 | 369 |
358 void | 370 void |
359 ngx_event_connect_peer_failed(ngx_peer_connection_t *pc, ngx_uint_t down) | 371 ngx_event_connect_peer_failed(ngx_peer_connection_t *pc, ngx_uint_t down) |
360 { | 372 { |
361 time_t now; | 373 time_t now; |
374 ngx_peer_t *peer; | |
362 | 375 |
363 if (down) { | 376 if (down) { |
364 now = ngx_time(); | 377 now = ngx_time(); |
365 | 378 |
366 /* ngx_lock_mutex(pc->peers->mutex); */ | 379 /* ngx_lock_mutex(pc->peers->mutex); */ |
367 | 380 |
368 pc->peers->peer[pc->cur_peer].fails++; | 381 peer = &pc->peers->peer[pc->cur_peer]; |
369 pc->peers->peer[pc->cur_peer].accessed = now; | 382 |
383 peer->fails++; | |
384 peer->accessed = now; | |
385 | |
386 if (peer->current_weight > 1) { | |
387 peer->current_weight /= 2; | |
388 } | |
370 | 389 |
371 /* ngx_unlock_mutex(pc->peers->mutex); */ | 390 /* ngx_unlock_mutex(pc->peers->mutex); */ |
372 } | 391 } |
373 | 392 |
374 pc->cur_peer++; | 393 pc->cur_peer++; |