Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 8125:cffaf3f2eec8
Lingering close for connections with pipelined requests.
This is expected to help with clients using pipelining with some constant
depth, such as apt[1][2].
When downloading many resources, apt uses pipelining with some constant
depth, a number of requests in flight. This essentially means that after
receiving a response it sends an additional request to the server, and
this can result in requests arriving to the server at any time. Further,
additional requests are sent one-by-one, and can be easily seen as such
(neither as pipelined, nor followed by pipelined requests).
The only safe approach to close such connections (for example, when
keepalive_requests is reached) is with lingering. To do so, now nginx
monitors if pipelining was used on the connection, and if it was, closes
the connection with lingering.
[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=973861#10
[2] https://mailman.nginx.org/pipermail/nginx-devel/2023-January/ZA2SP5SJU55LHEBCJMFDB2AZVELRLTHI.html
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 02 Feb 2023 23:38:48 +0300 |
parents | c263f9ffa1fd |
children | 0af598651e33 |
comparison
equal
deleted
inserted
replaced
8124:f5515e727656 | 8125:cffaf3f2eec8 |
---|---|
2751 | 2751 |
2752 if (clcf->lingering_close == NGX_HTTP_LINGERING_ALWAYS | 2752 if (clcf->lingering_close == NGX_HTTP_LINGERING_ALWAYS |
2753 || (clcf->lingering_close == NGX_HTTP_LINGERING_ON | 2753 || (clcf->lingering_close == NGX_HTTP_LINGERING_ON |
2754 && (r->lingering_close | 2754 && (r->lingering_close |
2755 || r->header_in->pos < r->header_in->last | 2755 || r->header_in->pos < r->header_in->last |
2756 || r->connection->read->ready))) | 2756 || r->connection->read->ready |
2757 || r->connection->pipeline))) | |
2757 { | 2758 { |
2758 ngx_http_set_lingering_close(r->connection); | 2759 ngx_http_set_lingering_close(r->connection); |
2759 return; | 2760 return; |
2760 } | 2761 } |
2761 | 2762 |
3121 | 3122 |
3122 c->data = r; | 3123 c->data = r; |
3123 | 3124 |
3124 c->sent = 0; | 3125 c->sent = 0; |
3125 c->destroyed = 0; | 3126 c->destroyed = 0; |
3127 c->pipeline = 1; | |
3126 | 3128 |
3127 if (rev->timer_set) { | 3129 if (rev->timer_set) { |
3128 ngx_del_timer(rev); | 3130 ngx_del_timer(rev); |
3129 } | 3131 } |
3130 | 3132 |