Welcome! Log In Create A New Profile

Advanced

[nginx] Cancel keepalive and lingering close on EOF better (ticket #2145).

Sergey Kandaurov
March 24, 2021 07:18AM
details: https://hg.nginx.org/nginx/rev/4a9d28f8f39e
branches:
changeset: 7804:4a9d28f8f39e
user: Sergey Kandaurov <pluknet@nginx.com>
date: Wed Mar 24 14:03:33 2021 +0300
description:
Cancel keepalive and lingering close on EOF better (ticket #2145).

Unlike in 75e908236701, which added the logic to ngx_http_finalize_request(),
this change moves it to a more generic routine ngx_http_finalize_connection()
to cover cases when a request is finalized with NGX_DONE.

In particular, this fixes unwanted connection transition into the keepalive
state after receiving EOF while discarding request body. With edge-triggered
event methods that means the connection will last for extra seconds as set in
the keepalive_timeout directive.

diffstat:

src/http/ngx_http_request.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diffs (27 lines):

diff -r 6df9d7df2784 -r 4a9d28f8f39e src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c Tue Mar 23 16:52:23 2021 +0300
+++ b/src/http/ngx_http_request.c Wed Mar 24 14:03:33 2021 +0300
@@ -2643,11 +2643,6 @@ ngx_http_finalize_request(ngx_http_reque
ngx_del_timer(c->write);
}

- if (c->read->eof) {
- ngx_http_close_request(r, 0);
- return;
- }
-
ngx_http_finalize_connection(r);
}

@@ -2746,6 +2741,11 @@ ngx_http_finalize_connection(ngx_http_re

r = r->main;

+ if (r->connection->read->eof) {
+ ngx_http_close_request(r, 0);
+ return;
+ }
+
if (r->reading_body) {
r->keepalive = 0;
r->lingering_close = 1;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Cancel keepalive and lingering close on EOF better (ticket #2145).

Sergey Kandaurov 324 March 24, 2021 07:18AM



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

Online Users

Guests: 156
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