# HG changeset patch # User Igor Sysoev # Date 1067271377 0 # Node ID 88abd07d9f62b2f63eb84e2a04f0f8b47e6a4afa # Parent e7e094d34162e01c6f8a36d25d993a33ab4120a2 nginx-0.0.1-2003-10-27-19:16:17 import diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c --- a/src/event/modules/ngx_kqueue_module.c +++ b/src/event/modules/ngx_kqueue_module.c @@ -201,7 +201,7 @@ static int ngx_kqueue_add_event(ngx_even { c = ev->data; ngx_log_error(NGX_LOG_ALERT, ev->log, 0, - "previous event were not passed in kernel", c->fd); + "previous event on #%d were not passed in kernel", c->fd); return NGX_ERROR; } diff --git a/src/event/ngx_event_connect.c b/src/event/ngx_event_connect.c --- a/src/event/ngx_event_connect.c +++ b/src/event/ngx_event_connect.c @@ -38,8 +38,6 @@ int ngx_event_connect_peer(ngx_peer_conn pc->cached = 0; pc->connection = NULL; - peer = &pc->peers->peers[0]; - if (pc->peers->number > 1) { /* there are several peers */ @@ -85,6 +83,8 @@ int ngx_event_connect_peer(ngx_peer_conn } } + peer = &pc->peers->peers[pc->cur_peer]; + /* ngx_unlock_mutex(pc->peers->mutex); */ #if 0 @@ -182,6 +182,8 @@ int ngx_event_connect_peer(ngx_peer_conn addr.sin_addr.s_addr = peer->addr; addr.sin_port = peer->port; +ngx_log_debug(pc->log, "CONNECT: %s" _ peer->addr_port_text.data); + rc = connect(s, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)); if (rc == -1) { @@ -232,6 +234,12 @@ int ngx_event_connect_peer(ngx_peer_conn void ngx_event_connect_peer_failed(ngx_peer_connection_t *pc) { + pc->cur_peer++; + + if (pc->cur_peer >= pc->peers->number) { + pc->cur_peer = 0; + } + pc->tries--; return; diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -457,6 +457,7 @@ static void ngx_http_proxy_send_request( return; } + ngx_event_connect_peer_failed(&p->upstream); ngx_http_proxy_close_connection(c); } diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -629,7 +629,7 @@ static void ngx_http_process_request_hea return; } - if (r->header_timeout_set) { + if (rev->timer_set) { ngx_del_timer(rev); } diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c --- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -157,6 +157,12 @@ int ngx_http_special_response_handler(ng ngx_chain_t *out, **ll, *cl; ngx_http_core_loc_conf_t *clcf; + rc = ngx_http_discard_body(r); + + if (rc != NGX_OK) { + return rc; + } + r->headers_out.status = error; if (error < NGX_HTTP_BAD_REQUEST) {