Mercurial > hg > nginx-quic
diff src/http/ngx_http_request.c @ 8367:4a9d28f8f39e
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.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 24 Mar 2021 14:03:33 +0300 |
parents | 3e83336cda5b |
children | f1986657fc26 1336a33cff33 ae70fcb8ac93 |
line wrap: on
line diff
--- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -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;