]> git.kaiwu.me - nginx.git/commit
Avoid sending "Connection: keep-alive" when shutting down.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 10 Jan 2022 23:23:49 +0000 (02:23 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 10 Jan 2022 23:23:49 +0000 (02:23 +0300)
commit22d4ff08bbe764997d157690e422d1077f543908
tree914d8155937fb36d83372cc9a6e961994316aa7d
parent96c342e56035a9676180d03b4659d5b05b9c6b07
Avoid sending "Connection: keep-alive" when shutting down.

When a worker process is shutting down, keepalive is not used: this is checked
before the ngx_http_set_keepalive() call in ngx_http_finalize_connection().
Yet the "Connection: keep-alive" header was still sent, even if we know that
the worker process is shutting down, potentially resulting in additional
requests being sent to the connection which is going to be closed anyway.
While clients are expected to be able to handle asynchronous close events
(see ticket #1022), it is certainly possible to send the "Connection: close"
header instead, informing the client that the connection is going to be closed
and potentially saving some unneeded work.

With this change, we additionally check for worker process shutdown just
before sending response headers, and disable keepalive accordingly.
src/http/ngx_http_header_filter_module.c