diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2011-09-15 19:03:15 +0000 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2011-09-15 19:03:15 +0000 |
commit | 2d6be3fe93201552439c48b7f90744746b18a233 (patch) | |
tree | 128d783b16ebda6315b212603395843f4cb312b4 /src | |
parent | a746bab7c113840246159a805e544457161c1d86 (diff) | |
download | nginx-2d6be3fe93201552439c48b7f90744746b18a233.tar.gz nginx-2d6be3fe93201552439c48b7f90744746b18a233.zip |
Upstream: keepalive flag.
This patch introduces r->upstream->keepalive flag, which is set by protocol
handlers if connection to upstream is in good state and can be kept alive.
Diffstat (limited to 'src')
-rw-r--r-- | src/http/ngx_http_upstream.c | 9 | ||||
-rw-r--r-- | src/http/ngx_http_upstream.h | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 62009f6c7..4230abc49 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -1297,6 +1297,8 @@ ngx_http_upstream_reinit(ngx_http_request_t *r, ngx_http_upstream_t *u) return NGX_ERROR; } + u->keepalive = 0; + ngx_memzero(&u->headers_in, sizeof(ngx_http_upstream_headers_in_t)); u->headers_in.content_length_n = -1; @@ -2006,6 +2008,11 @@ ngx_http_upstream_process_body_in_memory(ngx_http_request_t *r, } } + if (u->length == 0) { + ngx_http_upstream_finalize_request(r, u, 0); + return; + } + if (ngx_handle_read_event(rev, 0) != NGX_OK) { ngx_http_upstream_finalize_request(r, u, NGX_ERROR); return; @@ -2126,7 +2133,7 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u) return; } - if (u->peer.connection->read->ready) { + if (u->peer.connection->read->ready || u->length == 0) { ngx_http_upstream_process_non_buffered_upstream(r, u); } } diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h index c3f706e14..6e62044dc 100644 --- a/src/http/ngx_http_upstream.h +++ b/src/http/ngx_http_upstream.h @@ -308,6 +308,7 @@ struct ngx_http_upstream_s { #endif unsigned buffering:1; + unsigned keepalive:1; unsigned request_sent:1; unsigned header_sent:1; |