Mercurial > hg > nginx-quic
comparison 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 |
comparison
equal
deleted
inserted
replaced
8366:6df9d7df2784 | 8367:4a9d28f8f39e |
---|---|
2641 if (c->write->timer_set) { | 2641 if (c->write->timer_set) { |
2642 c->write->delayed = 0; | 2642 c->write->delayed = 0; |
2643 ngx_del_timer(c->write); | 2643 ngx_del_timer(c->write); |
2644 } | 2644 } |
2645 | 2645 |
2646 if (c->read->eof) { | |
2647 ngx_http_close_request(r, 0); | |
2648 return; | |
2649 } | |
2650 | |
2651 ngx_http_finalize_connection(r); | 2646 ngx_http_finalize_connection(r); |
2652 } | 2647 } |
2653 | 2648 |
2654 | 2649 |
2655 static void | 2650 static void |
2743 ngx_http_close_request(r, 0); | 2738 ngx_http_close_request(r, 0); |
2744 return; | 2739 return; |
2745 } | 2740 } |
2746 | 2741 |
2747 r = r->main; | 2742 r = r->main; |
2743 | |
2744 if (r->connection->read->eof) { | |
2745 ngx_http_close_request(r, 0); | |
2746 return; | |
2747 } | |
2748 | 2748 |
2749 if (r->reading_body) { | 2749 if (r->reading_body) { |
2750 r->keepalive = 0; | 2750 r->keepalive = 0; |
2751 r->lingering_close = 1; | 2751 r->lingering_close = 1; |
2752 } | 2752 } |