Mercurial > hg > nginx-quic
diff src/http/modules/proxy/ngx_http_proxy_upstream.c @ 313:98f1a8028067
nginx-0.0.3-2004-04-13-19:08:48 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 13 Apr 2004 15:08:48 +0000 |
parents | bcbe876f4262 |
children | d71c87d11b16 |
line wrap: on
line diff
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c +++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c @@ -327,19 +327,20 @@ static void ngx_http_proxy_init_upstream r->connection->read->event_handler = ngx_http_proxy_check_broken_connection; - if ((ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_HAVE_KQUEUE_EVENT)) - && !r->connection->write->active) - { + if (ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_HAVE_KQUEUE_EVENT)) { + /* kqueue allows to detect when client closes prematurely connection */ r->connection->write->event_handler = ngx_http_proxy_check_broken_connection; - if (ngx_add_event(r->connection->write, NGX_WRITE_EVENT, + if (!r->connection->write->active) { + if (ngx_add_event(r->connection->write, NGX_WRITE_EVENT, NGX_CLEAR_EVENT) == NGX_ERROR) - { - ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); - return; + { + ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); + return; + } } } @@ -560,6 +561,9 @@ static void ngx_http_proxy_connect(ngx_h rc = ngx_event_connect_peer(&p->upstream->peer); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0, + "http proxy connect: %d", rc); + if (rc == NGX_ERROR) { ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); return; @@ -573,14 +577,13 @@ static void ngx_http_proxy_connect(ngx_h return; } - p->upstream->peer.connection->data = p; - p->upstream->peer.connection->write->event_handler = - ngx_http_proxy_send_request_handler; - p->upstream->peer.connection->read->event_handler = - ngx_http_proxy_process_upstream_status_line; - r = p->request; c = p->upstream->peer.connection; + + c->data = p; + c->write->event_handler = ngx_http_proxy_send_request_handler; + c->read->event_handler = ngx_http_proxy_process_upstream_status_line; + c->pool = r->pool; c->read->log = c->write->log = c->log = r->connection->log; @@ -613,6 +616,11 @@ static void ngx_http_proxy_connect(ngx_h if (rc == NGX_AGAIN) { ngx_add_timer(c->write, p->lcf->connect_timeout); + + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, + "http proxy connect handler: " PTR_FMT, + c->write->event_handler); + return; } @@ -638,6 +646,9 @@ static void ngx_http_proxy_send_request( c = p->upstream->peer.connection; + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, + "http proxy send request"); + #if (HAVE_KQUEUE) if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) @@ -715,8 +726,7 @@ static void ngx_http_proxy_send_request( } #endif - p->upstream->peer.connection->write->event_handler = - ngx_http_proxy_dummy_handler; + c->write->event_handler = ngx_http_proxy_dummy_handler; if (ngx_handle_level_write_event(c->write) == NGX_ERROR) { ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); @@ -733,6 +743,9 @@ static void ngx_http_proxy_send_request_ c = wev->data; p = c->data; + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, + "http proxy send request handler"); + if (wev->timedout) { p->action = "sending request to upstream"; ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_TIMEOUT);