diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2021-02-11 21:52:09 +0300 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2021-02-11 21:52:09 +0300 |
commit | fb2a2152d756f23ce191ab109116585f90acf087 (patch) | |
tree | d52fd9885ae461bca64cc3f51452e76d6ad6f77f /src/http/ngx_http_request.c | |
parent | 327e21c43293ecfdbd116bd572ee08b7d8066b24 (diff) | |
download | nginx-fb2a2152d756f23ce191ab109116585f90acf087.tar.gz nginx-fb2a2152d756f23ce191ab109116585f90acf087.zip |
Reuse of connections in lingering close.
This is particularly important in HTTP/2, where keepalive connections
are closed with lingering. Before the patch, reusing a keepalive HTTP/2
connection resulted in the connection waiting for lingering close to
remain in the reusable connections queue, preventing ngx_drain_connections()
from closing additional connections.
The patch fixes it by marking the connection reusable again, and so
moving it in the reusable connections queue. Further, it makes actually
possible to reuse such connections if needed.
Diffstat (limited to 'src/http/ngx_http_request.c')
-rw-r--r-- | src/http/ngx_http_request.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 68d81e932..d129f8079 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -3437,6 +3437,9 @@ ngx_http_set_lingering_close(ngx_connection_t *c) return; } + c->close = 0; + ngx_reusable_connection(c, 1); + ngx_add_timer(rev, clcf->lingering_timeout); if (rev->ready) { @@ -3461,7 +3464,7 @@ ngx_http_lingering_close_handler(ngx_event_t *rev) ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http lingering close handler"); - if (rev->timedout) { + if (rev->timedout || c->close) { ngx_http_close_request(r, 0); return; } |