Mercurial > hg > nginx
changeset 3984:3e51832c8215
lingering_close "off|on|always"
patch by Maxim Dounin
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 01 Aug 2011 13:26:55 +0000 |
parents | e126d997cbc6 |
children | 07d1aa82899b |
files | src/http/ngx_http_core_module.c src/http/ngx_http_core_module.h src/http/ngx_http_request.c |
diffstat | 3 files changed, 31 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/ngx_http_core_module.c Mon Aug 01 13:08:03 2011 +0000 +++ b/src/http/ngx_http_core_module.c Mon Aug 01 13:26:55 2011 +0000 @@ -126,6 +126,14 @@ }; +static ngx_conf_enum_t ngx_http_core_lingering_close[] = { + { ngx_string("off"), NGX_HTTP_LINGERING_OFF }, + { ngx_string("on"), NGX_HTTP_LINGERING_ON }, + { ngx_string("always"), NGX_HTTP_LINGERING_ALWAYS }, + { ngx_null_string, 0 } +}; + + static ngx_conf_enum_t ngx_http_core_if_modified_since[] = { { ngx_string("off"), NGX_HTTP_IMS_OFF }, { ngx_string("exact"), NGX_HTTP_IMS_EXACT }, @@ -531,6 +539,13 @@ 0, NULL }, + { ngx_string("lingering_close"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_enum_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_core_loc_conf_t, lingering_close), + &ngx_http_core_lingering_close }, + { ngx_string("lingering_time"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_conf_set_msec_slot, @@ -3250,6 +3265,7 @@ clcf->keepalive_timeout = NGX_CONF_UNSET_MSEC; clcf->keepalive_header = NGX_CONF_UNSET; clcf->keepalive_requests = NGX_CONF_UNSET_UINT; + clcf->lingering_close = NGX_CONF_UNSET_UINT; clcf->lingering_time = NGX_CONF_UNSET_MSEC; clcf->lingering_timeout = NGX_CONF_UNSET_MSEC; clcf->resolver_timeout = NGX_CONF_UNSET_MSEC; @@ -3466,6 +3482,8 @@ prev->keepalive_header, 0); ngx_conf_merge_uint_value(conf->keepalive_requests, prev->keepalive_requests, 100); + ngx_conf_merge_msec_value(conf->lingering_close, + prev->lingering_close, NGX_HTTP_LINGERING_ON); ngx_conf_merge_msec_value(conf->lingering_time, prev->lingering_time, 30000); ngx_conf_merge_msec_value(conf->lingering_timeout,
--- a/src/http/ngx_http_core_module.h Mon Aug 01 13:08:03 2011 +0000 +++ b/src/http/ngx_http_core_module.h Mon Aug 01 13:26:55 2011 +0000 @@ -33,6 +33,11 @@ #define NGX_HTTP_SATISFY_ANY 1 +#define NGX_HTTP_LINGERING_OFF 0 +#define NGX_HTTP_LINGERING_ON 1 +#define NGX_HTTP_LINGERING_ALWAYS 2 + + #define NGX_HTTP_IMS_OFF 0 #define NGX_HTTP_IMS_EXACT 1 #define NGX_HTTP_IMS_BEFORE 2 @@ -356,6 +361,7 @@ ngx_uint_t keepalive_requests; /* keepalive_requests */ ngx_uint_t keepalive_disable; /* keepalive_disable */ ngx_uint_t satisfy; /* satisfy */ + ngx_uint_t lingering_close; /* lingering_close */ ngx_uint_t if_modified_since; /* if_modified_since */ ngx_uint_t client_body_in_file_only; /* client_body_in_file_only */
--- a/src/http/ngx_http_request.c Mon Aug 01 13:08:03 2011 +0000 +++ b/src/http/ngx_http_request.c Mon Aug 01 13:26:55 2011 +0000 @@ -2142,11 +2142,13 @@ { ngx_http_set_keepalive(r); return; - - } else if (clcf->lingering_timeout > 0 - && (r->lingering_close - || r->header_in->pos < r->header_in->last - || r->connection->read->ready)) + } + + if (clcf->lingering_close == NGX_HTTP_LINGERING_ALWAYS + || (clcf->lingering_close == NGX_HTTP_LINGERING_ON + && (r->lingering_close + || r->header_in->pos < r->header_in->last + || r->connection->read->ready))) { ngx_http_set_lingering_close(r); return;