Sergey Kandaurov
January 10, 2020 01:02PM
> On 7 Jan 2020, at 19:12, ak638 <nginx-forum@forum.nginx.org> wrote:
>
> Hi,
>
> I wonder if it's a bug. It confused me.
> recv in ngx_http_discard_request_body return 0, but ignored(suppose to close
> conntection soon). So the connection will stay in keepalive timer untill
> timeout, while client already closed and server stay in CLOSE_WAIT.

Hello.

This is a known issue. It would be nice if
you could try and report back if this patch helped you.

# HG changeset patch
# User Sergey Kandaurov <pluknet@nginx.com>
# Date 1534236841 -10800
# Tue Aug 14 11:54:01 2018 +0300
# Node ID b71df78c7dd02f0adf817a5af1931e8e4e9365d0
# Parent 70c6b08973a02551612da4a4273757dc77c70ae2
Cancel keepalive and lingering close on EOF better.

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.

diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -2497,11 +2497,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);
}

@@ -2600,6 +2595,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;


--
Sergey Kandaurov

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

ngx_http_discard_request_body may make keepalive connection hang in CLOSE_WAIT

ak638 January 07, 2020 11:12AM

Re: ngx_http_discard_request_body may make keepalive connection hang in CLOSE_WAIT

Sergey Kandaurov January 10, 2020 01:02PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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