comparison src/http/ngx_http_upstream.c @ 4120:42135dd1f0ea

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 15 Sep 2011 19:03:15 +0000
parents b66712cde67d
children 0ee350b5177c
comparison
equal deleted inserted replaced
4119:b66712cde67d 4120:42135dd1f0ea
1295 1295
1296 if (u->reinit_request(r) != NGX_OK) { 1296 if (u->reinit_request(r) != NGX_OK) {
1297 return NGX_ERROR; 1297 return NGX_ERROR;
1298 } 1298 }
1299 1299
1300 u->keepalive = 0;
1301
1300 ngx_memzero(&u->headers_in, sizeof(ngx_http_upstream_headers_in_t)); 1302 ngx_memzero(&u->headers_in, sizeof(ngx_http_upstream_headers_in_t));
1301 u->headers_in.content_length_n = -1; 1303 u->headers_in.content_length_n = -1;
1302 1304
1303 if (ngx_list_init(&u->headers_in.headers, r->pool, 8, 1305 if (ngx_list_init(&u->headers_in.headers, r->pool, 8,
1304 sizeof(ngx_table_elt_t)) 1306 sizeof(ngx_table_elt_t))
2004 if (!rev->ready) { 2006 if (!rev->ready) {
2005 break; 2007 break;
2006 } 2008 }
2007 } 2009 }
2008 2010
2011 if (u->length == 0) {
2012 ngx_http_upstream_finalize_request(r, u, 0);
2013 return;
2014 }
2015
2009 if (ngx_handle_read_event(rev, 0) != NGX_OK) { 2016 if (ngx_handle_read_event(rev, 0) != NGX_OK) {
2010 ngx_http_upstream_finalize_request(r, u, NGX_ERROR); 2017 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
2011 return; 2018 return;
2012 } 2019 }
2013 2020
2124 if (ngx_http_send_special(r, NGX_HTTP_FLUSH) == NGX_ERROR) { 2131 if (ngx_http_send_special(r, NGX_HTTP_FLUSH) == NGX_ERROR) {
2125 ngx_http_upstream_finalize_request(r, u, 0); 2132 ngx_http_upstream_finalize_request(r, u, 0);
2126 return; 2133 return;
2127 } 2134 }
2128 2135
2129 if (u->peer.connection->read->ready) { 2136 if (u->peer.connection->read->ready || u->length == 0) {
2130 ngx_http_upstream_process_non_buffered_upstream(r, u); 2137 ngx_http_upstream_process_non_buffered_upstream(r, u);
2131 } 2138 }
2132 } 2139 }
2133 2140
2134 return; 2141 return;