diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2004-03-30 06:27:36 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2004-03-30 06:27:36 +0000 |
| commit | 6881bfb99063e3d42abaa313641b311c6fc3522d (patch) | |
| tree | 1df669d89a2f58b450947901b1f41eb407dbf540 /src/http/modules/proxy | |
| parent | 11dbe97ca401221313dc233aa2d6f67dfcaef1a7 (diff) | |
| download | nginx-6881bfb99063e3d42abaa313641b311c6fc3522d.tar.gz nginx-6881bfb99063e3d42abaa313641b311c6fc3522d.tar.bz2 | |
nginx-0.0.3-2004-03-30-10:27:36 import
Diffstat (limited to 'src/http/modules/proxy')
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 19 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.h | 2 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_upstream.c | 54 |
3 files changed, 37 insertions, 38 deletions
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 3fc8d0ef4..8f0336a9b 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -374,28 +374,29 @@ static int ngx_http_proxy_handler(ngx_http_request_t *r) } -void ngx_http_proxy_check_broken_connection(ngx_event_t *wev) +void ngx_http_proxy_check_broken_connection(ngx_event_t *ev) { ngx_connection_t *c; ngx_http_request_t *r; ngx_http_proxy_ctx_t *p; - ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, "http proxy check client"); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, 0, + "http proxy check client, write event:%d", ev->write); - c = wev->data; + c = ev->data; r = c->data; p = ngx_http_get_module_ctx(r, ngx_http_proxy_module); #if (HAVE_KQUEUE) - if (wev->kq_eof) { - wev->eof = 1; + if (ev->kq_eof) { + ev->eof = 1; - if (wev->kq_errno) { - wev->error = 1; + if (ev->kq_errno) { + ev->error = 1; } if (!p->cachable && p->upstream->peer.connection) { - ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno, + ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, "kevent() reported that client have closed " "prematurely connection, " "so upstream connection is closed too"); @@ -403,7 +404,7 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *wev) return; } - ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno, + ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, "kevent() reported that client have closed " "prematurely connection"); diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h index 210ca89f8..d204cac59 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.h +++ b/src/http/modules/proxy/ngx_http_proxy_handler.h @@ -227,7 +227,7 @@ void ngx_http_proxy_cache_busy_lock(ngx_http_proxy_ctx_t *p); #endif -void ngx_http_proxy_check_broken_connection(ngx_event_t *wev); +void ngx_http_proxy_check_broken_connection(ngx_event_t *ev); void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev); void ngx_http_proxy_upstream_busy_lock(ngx_http_proxy_ctx_t *p); diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c index 6bc11a25d..00a078009 100644 --- a/src/http/modules/proxy/ngx_http_proxy_upstream.c +++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c @@ -70,41 +70,37 @@ int ngx_http_proxy_request_upstream(ngx_http_proxy_ctx_t *p) } r->request_body = rb; - if (r->headers_in.content_length_n > 0) { - - if (!(tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) { - return NGX_HTTP_INTERNAL_SERVER_ERROR; - } + if (r->headers_in.content_length_n <= 0) { + ngx_http_proxy_init_upstream(p); + return NGX_DONE; + } - tf->file.fd = NGX_INVALID_FILE; - tf->file.log = r->connection->log; - tf->path = p->lcf->temp_path; - tf->pool = r->pool; - tf->warn = "a client request body is buffered to a temporary file"; - /* tf->persistent = 0; */ + if (!(tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) { + return NGX_HTTP_INTERNAL_SERVER_ERROR; + } - rb->buf_size = p->lcf->request_buffer_size; - rb->handler = ngx_http_proxy_init_upstream; - rb->data = p; - /* rb->bufs = NULL; */ - /* rb->buf = NULL; */ - /* rb->rest = 0; */ + tf->file.fd = NGX_INVALID_FILE; + tf->file.log = r->connection->log; + tf->path = p->lcf->temp_path; + tf->pool = r->pool; + tf->warn = "a client request body is buffered to a temporary file"; + /* tf->persistent = 0; */ - rb->temp_file = tf; + rb->buf_size = p->lcf->request_buffer_size; + rb->handler = ngx_http_proxy_init_upstream; + rb->data = p; + /* rb->bufs = NULL; */ + /* rb->buf = NULL; */ + /* rb->rest = 0; */ - rc = ngx_http_read_client_request_body(r); + rb->temp_file = tf; - if (rc == NGX_AGAIN) { - return NGX_DONE; - } + rc = ngx_http_read_client_request_body(r); - if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { - return rc; - } + if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { + return rc; } - ngx_http_proxy_init_upstream(p); - return NGX_DONE; } @@ -323,13 +319,15 @@ static void ngx_http_proxy_init_upstream(void *data) r = p->request; ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "http proxy set timer: %d", + "http proxy init upstream, client timer: %d", r->connection->read->timer_set); if (r->connection->read->timer_set) { ngx_del_timer(r->connection->read); } + 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) { |
