Welcome! Log In Create A New Profile

Advanced

[PATCH] HTTP: trigger lingering close when keepalive connection will be closed

January 18, 2023 10:30AM
# HG changeset patch
# User Miao Wang <shankerwangmiao@gmail.com>
# Date 1674055068 -28800
# Wed Jan 18 23:17:48 2023 +0800
# Node ID 73aa64bd29f3dec9e43e97560d6b5a07cdf40063
# Parent 07b0bee87f32be91a33210bc06973e07c4c1dac9
HTTP: trigger lingering close when keepalive connection will be closed

When finalizing a request, if the request is not keepalive but
its connection has served more than one request, then the connection
has been a keepalive connection previously and this connection will
be closed after this response. In this condition, it is likely that
there are pipelined requests following this request, which we should
ignore. As a result, lingering close is necessary in this case.

Without this patch, nginx (with its default configuration) will send
out TCP RST when there are more pipelined requests. The symptom is
obvious when nginx is serving a debian repository and apt is
downloading massive of packages. See [1]. It becomes more obvious
when `keepalive_requests` is lower or nginx is under a relative
higher load, and it disappears when specifying
`lingering_close always`.

[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=973861#10

diff -r 07b0bee87f32 -r 73aa64bd29f3 src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c Wed Dec 21 14:53:27 2022 +0300
+++ b/src/http/ngx_http_request.c Wed Jan 18 23:17:48 2023 +0800
@@ -2749,6 +2749,10 @@
return;
}

+ if (!r->keepalive && r->connection->requests > 1) {
+ r->lingering_close = 1;
+ }
+
if (clcf->lingering_close == NGX_HTTP_LINGERING_ALWAYS
|| (clcf->lingering_close == NGX_HTTP_LINGERING_ON
&& (r->lingering_close
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] HTTP: trigger lingering close when keepalive connection will be closed

shankerwangmiao 651 January 18, 2023 10:30AM

Re: [PATCH] HTTP: trigger lingering close when keepalive connection will be closed

Maxim Dounin 182 January 22, 2023 11:06PM

Re: [PATCH] HTTP: trigger lingering close when keepalive connection will be closed

shankerwangmiao 147 January 23, 2023 06:02AM

Re: [PATCH] HTTP: trigger lingering close when keepalive connection will be closed

Maxim Dounin 107 January 24, 2023 09:18PM

Re: [PATCH] HTTP: trigger lingering close when keepalive connection will be closed

shankerwangmiao 182 January 24, 2023 11:50PM

Re: [PATCH] HTTP: trigger lingering close when keepalive connection will be closed

Maxim Dounin 114 January 26, 2023 11:02PM

Re: [PATCH] HTTP: trigger lingering close when keepalive connection will be closed

shankerwangmiao 129 January 27, 2023 07:12AM

Re: [PATCH] HTTP: trigger lingering close when keepalive connection will be closed

Maxim Dounin 112 January 27, 2023 04:58PM

Re: [PATCH] HTTP: trigger lingering close when keepalive connection will be closed

Sergey Kandaurov 148 February 02, 2023 09:54AM

Re: [PATCH] HTTP: trigger lingering close when keepalive connection will be closed

Maxim Dounin 254 February 02, 2023 08:52PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 237
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready