Welcome! Log In Create A New Profile

Advanced

[nginx] Additional connections reuse.

Maxim Dounin
February 11, 2021 02:58PM
details: https://hg.nginx.org/nginx/rev/6d98f29867e8
branches:
changeset: 7767:6d98f29867e8
user: Maxim Dounin <mdounin@mdounin.ru>
date: Thu Feb 11 21:52:11 2021 +0300
description:
Additional connections reuse.

If ngx_drain_connections() fails to immediately reuse any connections
and there are no free connections, it now additionally tries to reuse
a connection again. This helps to provide at least one free connection
in case of HTTP/2 with lingering close, where merely trying to reuse
a connection once does not free it, but makes it reusable again,
waiting for lingering close.

diffstat:

src/core/ngx_connection.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)

diffs (33 lines):

diff -r 3e83336cda5b -r 6d98f29867e8 src/core/ngx_connection.c
--- a/src/core/ngx_connection.c Thu Feb 11 21:52:09 2021 +0300
+++ b/src/core/ngx_connection.c Thu Feb 11 21:52:11 2021 +0300
@@ -1310,6 +1310,7 @@ ngx_drain_connections(ngx_cycle_t *cycle
cycle->connection_n);
}

+ c = NULL;
n = ngx_max(ngx_min(32, cycle->reusable_connections_n / 8), 1);

for (i = 0; i < n; i++) {
@@ -1326,6 +1327,21 @@ ngx_drain_connections(ngx_cycle_t *cycle
c->close = 1;
c->read->handler(c->read);
}
+
+ if (cycle->free_connection_n == 0 && c && c->reusable) {
+
+ /*
+ * if no connections were freed, try to reuse the last
+ * connection again: this should free it as long as
+ * previous reuse moved it to lingering close
+ */
+
+ ngx_log_debug0(NGX_LOG_DEBUG_CORE, c->log, 0,
+ "reusing connection again");
+
+ c->close = 1;
+ c->read->handler(c->read);
+ }
}


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Additional connections reuse.

Maxim Dounin 65 February 11, 2021 02:58PM



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

Online Users

Guests: 76
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready