fix: don't count reused connections as new (#16414)
Ilya Mashchenko committed
Nov 14, 2023 at 18:39 UTC
f9db941faf3e5bb80144640b7f6059ed42a5ff4d
1 file changed
+4
-6
web/server/web_client_cache.c
+4
-6
@@ -91,20 +91,19 @@ struct web_client *web_client_get_from_cache(void) {
91
// get it from avail
92
DOUBLE_LINKED_LIST_REMOVE_ITEM_UNSAFE(web_clients_cache.avail.head, w, cache.prev, cache.next);
93
web_clients_cache.avail.count--;
94
- spinlock_unlock(&web_clients_cache.avail.spinlock);
94
95
+ spinlock_unlock(&web_clients_cache.avail.spinlock);
96
web_client_reuse_from_cache(w);
97
-
97
spinlock_lock(&web_clients_cache.used.spinlock);
98
+
99
web_clients_cache.used.reused++;
100
}
101
else {
102
spinlock_unlock(&web_clients_cache.avail.spinlock);
103
-
104
- // allocate it
103
w = web_client_create(&netdata_buffers_statistics.buffers_web);
106
-
104
spinlock_lock(&web_clients_cache.used.spinlock);
105
+
106
+ w->id = global_statistics_web_client_connected();
107
web_clients_cache.used.allocated++;
108
}
109
@@ -115,7 +114,6 @@ struct web_client *web_client_get_from_cache(void) {
114
115
// initialize it
116
w->use_count++;
118
- w->id = global_statistics_web_client_connected();
117
w->mode = WEB_CLIENT_MODE_GET;
118
119
return w;