Skip to content

Instantly share code, notes, and snippets.

@hongzhidao
Created September 26, 2022 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hongzhidao/51fbc5169f22bd725d99446eca47e346 to your computer and use it in GitHub Desktop.
Save hongzhidao/51fbc5169f22bd725d99446eca47e346 to your computer and use it in GitHub Desktop.
# User Zhidao HONG <z.hong@f5.com>
# Date 1663779678 -28800
# Thu Sep 22 01:01:18 2022 +0800
# Node ID f57e9f89c3568c9150ca7a69c24ad3964859fa7d
# Parent 6b6b979e821420bba206c717b68e0420d01ab010
Status: fixed error connection statistics.
When proxy is used, the number of accepted connections is not counted,
This also results in the wrong number of active connections.
diff -r 6b6b979e8214 -r f57e9f89c356 docs/changes.xml
--- a/docs/changes.xml Mon Sep 19 02:45:44 2022 +0800
+++ b/docs/changes.xml Thu Sep 22 01:01:18 2022 +0800
@@ -37,6 +37,12 @@
</para>
</change>
+<change type="bugfix">
+<para>
+fix error connection statistics when using proxy.
+</para>
+</change>
+
</changes>
diff -r 6b6b979e8214 -r f57e9f89c356 src/nxt_conn.h
--- a/src/nxt_conn.h Mon Sep 19 02:45:44 2022 +0800
+++ b/src/nxt_conn.h Thu Sep 22 01:01:18 2022 +0800
@@ -312,8 +312,7 @@
\
nxt_queue_remove(&c->link); \
\
- c->idle = 0; \
- e->idle_conns_cnt--; \
+ e->idle_conns_cnt -= c->idle; \
} while (0)
diff -r 6b6b979e8214 -r f57e9f89c356 src/nxt_conn_close.c
--- a/src/nxt_conn_close.c Mon Sep 19 02:45:44 2022 +0800
+++ b/src/nxt_conn_close.c Thu Sep 22 01:01:18 2022 +0800
@@ -119,7 +119,9 @@
nxt_socket_close(task, c->socket.fd);
c->socket.fd = -1;
- engine->closed_conns_cnt++;
+ if (c->idle) {
+ engine->closed_conns_cnt++;
+ }
if (timers_pending == 0) {
nxt_work_queue_add(&engine->fast_work_queue,
@@ -155,7 +157,9 @@
nxt_socket_close(task, c->socket.fd);
c->socket.fd = -1;
- engine->closed_conns_cnt++;
+ if (c->idle) {
+ engine->closed_conns_cnt++;
+ }
}
nxt_work_queue_add(&engine->fast_work_queue, c->write_state->ready_handler,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment