Welcome! Log In Create A New Profile

Advanced

[PATCH] Be consistent with keepalive during graceful shutdown

Yuchen Wu via nginx-devel
January 17, 2019 02:30PM
# HG changeset patch
# User Yuchen Wu <yuchen@cloudflare.com>
# Date 1547749157 28800
# Thu Jan 17 10:19:17 2019 -0800
# Node ID 8a6290c41b33c664d52d7a472400381e71ecf171
# Parent 8acaa1161783347106dcaea574837e441e13b540
Be consistent with keepalive during graceful shutdown

Before, when nginx sends the Connection: Keep-Alive header and then
nginx decides to shutdown, it will close the connection. Downstream
may already reuse the connection for another request in the meanwhile.

This change allows one extra use of such a connection to make sure it
is closed cleanly.

diff -r 8acaa1161783 -r 8a6290c41b33 src/http/ngx_http_header_filter_module.c
--- a/src/http/ngx_http_header_filter_module.c Thu Dec 27 19:37:34 2018 +0300
+++ b/src/http/ngx_http_header_filter_module.c Thu Jan 17 10:19:17 2019 -0800
@@ -187,6 +187,10 @@
r->header_only = 1;
}

+ if (ngx_terminate || ngx_exiting) {
+ r->keepalive = 0;
+ }
+
if (r->headers_out.last_modified_time != -1) {
if (r->headers_out.status != NGX_HTTP_OK
&& r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT
diff -r 8acaa1161783 -r 8a6290c41b33 src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c Thu Dec 27 19:37:34 2018 +0300
+++ b/src/http/ngx_http_request.c Thu Jan 17 10:19:17 2019 -0800
@@ -2611,9 +2611,7 @@
r->lingering_close = 1;
}

- if (!ngx_terminate
- && !ngx_exiting
- && r->keepalive
+ if (r->keepalive
&& clcf->keepalive_timeout > 0)
{
ngx_http_set_keepalive(r);
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Be consistent with keepalive during graceful shutdown

Yuchen Wu via nginx-devel 293 January 17, 2019 02:30PM

Re: [PATCH] Be consistent with keepalive during graceful shutdown

Maxim Dounin 161 January 21, 2019 10:18AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

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