Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev ][Date Next ][Thread Prev ][Thread Next ][Date Index ][Thread Index ]
Re: Интересный эффект при proxy_next_upstream http_404
On Tue, 21 Jun 2005, Andrew Velikoredchanin wrote:
Интересный эффект заметил.
Если на фронтэнде стоит "proxy_next_upstream ... http_404;", а ни на одном
бэкэнде запрашиваемого файла нет, то фронтэнд продолжает перебирать бэкэнда
до бесконечности, т.е. соединение фактически виснет.
nginx последний 0.1.36
Это ошибка. Прилагаемый патч должен помочь.
Игорь Сысоев
http://sysoev.ru --- src/event/ngx_event_connect.c Mon Apr 18 00:59:54 2005
+++ src/event/ngx_event_connect.c Tue Jun 21 12:34:25 2005
@@ -376,18 +376,20 @@
void
-ngx_event_connect_peer_failed(ngx_peer_connection_t *pc)
+ngx_event_connect_peer_failed(ngx_peer_connection_t *pc, ngx_uint_t down)
{
time_t now;
- now = ngx_time();
+ if (down) {
+ now = ngx_time();
- /* ngx_lock_mutex(pc->peers->mutex); */
+ /* ngx_lock_mutex(pc->peers->mutex); */
- pc->peers->peer[pc->cur_peer].fails++;
- pc->peers->peer[pc->cur_peer].accessed = now;
+ pc->peers->peer[pc->cur_peer].fails++;
+ pc->peers->peer[pc->cur_peer].accessed = now;
- /* ngx_unlock_mutex(pc->peers->mutex); */
+ /* ngx_unlock_mutex(pc->peers->mutex); */
+ }
pc->cur_peer++;
--- src/event/ngx_event_connect.h Mon Apr 4 12:44:01 2005
+++ src/event/ngx_event_connect.h Tue Jun 21 12:34:39 2005
@@ -67,7 +67,7 @@
ngx_int_t ngx_event_connect_peer(ngx_peer_connection_t *pc);
-void ngx_event_connect_peer_failed(ngx_peer_connection_t *pc);
+void ngx_event_connect_peer_failed(ngx_peer_connection_t *pc, ngx_uint_t down);
#endif /* _NGX_EVENT_CONNECT_H_INCLUDED_ */
--- src/http/ngx_http_upstream.c Thu May 19 16:52:40 2005
+++ src/http/ngx_http_upstream.c Tue Jun 21 12:35:50 2005
@@ -1230,7 +1230,7 @@
ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u,
ngx_uint_t ft_type)
{
- ngx_uint_t status;
+ ngx_uint_t status, down;
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http next upstream, %xD", ft_type);
@@ -1239,10 +1239,14 @@
ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock);
#endif
- if (ft_type != NGX_HTTP_UPSTREAM_FT_HTTP_404) {
- ngx_event_connect_peer_failed(&u->peer);
+ if (ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_404) {
+ down = 0;
+ } else {
+ down = 1;
}
-
+
+ ngx_event_connect_peer_failed(&u->peer, down);
+
if (ft_type == NGX_HTTP_UPSTREAM_FT_TIMEOUT) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_ETIMEDOUT,
"upstream timed out");