]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Move ns_highwater_recursclients to highwater stats
authorAlessio Podda <alessio@isc.org>
Wed, 25 Mar 2026 12:12:41 +0000 (13:12 +0100)
committerAlessio Podda <alessio@isc.org>
Thu, 26 Mar 2026 09:19:25 +0000 (10:19 +0100)
Since it is impossible to increase an isc_statsmulti counter and
retrieve the new counter atomically, and we need the output of
recursclients in order to compute ns_highwater_recursive, we change the
recursclients counter to an isc_stats one.

bin/named/statschannel.c
lib/ns/include/ns/stats.h
lib/ns/query.c
tests/ns/query_test.c

index 17b33d7cf81756bc526a109ffa7cf1f609ad959e..91642857f6eec048cbf23e63ce4a94998df38c1f 100644 (file)
@@ -370,7 +370,6 @@ init_desc(void) {
        SET_NSSTATDESC(updatebadprereq,
                       "updates rejected due to prerequisite failure",
                       "UpdateBadPrereq");
-       SET_NSSTATDESC(recursclients, "recursing clients", "RecursClients");
        SET_NSSTATDESC(dns64, "queries answered by DNS64", "DNS64");
        SET_NSSTATDESC(ratedropped, "responses dropped for rate limits",
                       "RateDropped");
@@ -463,6 +462,8 @@ init_desc(void) {
                                "TCPConnHighWater");
        SET_NSHIGHWATERSTATDESC(recursive, "Recursive clients high-water",
                                "RecursHighwater");
+       SET_NSHIGHWATERSTATDESC(recursclients, "recursing clients",
+                               "RecursClients");
 
        INSIST(i == ns_highwater_max);
 
index c242f2c19c68fdbc7369b228b11d6b28becb48a0..bcc4d789c6885f23b10ddd74f4daa11b789f26e0 100644 (file)
@@ -67,63 +67,61 @@ enum {
        ns_statscounter_updatefail = 34,
        ns_statscounter_updatebadprereq = 35,
 
-       ns_statscounter_recursclients = 36,
+       ns_statscounter_dns64 = 36,
 
-       ns_statscounter_dns64 = 37,
+       ns_statscounter_ratedropped = 37,
+       ns_statscounter_rateslipped = 38,
 
-       ns_statscounter_ratedropped = 38,
-       ns_statscounter_rateslipped = 39,
+       ns_statscounter_rpz_rewrites = 39,
 
-       ns_statscounter_rpz_rewrites = 40,
+       ns_statscounter_udp = 40,
+       ns_statscounter_tcp = 41,
 
-       ns_statscounter_udp = 41,
-       ns_statscounter_tcp = 42,
+       ns_statscounter_nsidopt = 42,
+       ns_statscounter_expireopt = 43,
+       ns_statscounter_otheropt = 44,
+       ns_statscounter_ecsopt = 45,
+       ns_statscounter_padopt = 46,
+       ns_statscounter_keepaliveopt = 47,
+       ns_statscounter_zoneversionopt = 48,
 
-       ns_statscounter_nsidopt = 43,
-       ns_statscounter_expireopt = 44,
-       ns_statscounter_otheropt = 45,
-       ns_statscounter_ecsopt = 46,
-       ns_statscounter_padopt = 47,
-       ns_statscounter_keepaliveopt = 48,
-       ns_statscounter_zoneversionopt = 49,
+       ns_statscounter_nxdomainredirect = 49,
+       ns_statscounter_nxdomainredirect_rlookup = 50,
 
-       ns_statscounter_nxdomainredirect = 50,
-       ns_statscounter_nxdomainredirect_rlookup = 51,
+       ns_statscounter_cookiein = 51,
+       ns_statscounter_cookiebadsize = 52,
+       ns_statscounter_cookiebadtime = 53,
+       ns_statscounter_cookienomatch = 54,
+       ns_statscounter_cookiematch = 55,
+       ns_statscounter_cookienew = 56,
+       ns_statscounter_badcookie = 57,
 
-       ns_statscounter_cookiein = 52,
-       ns_statscounter_cookiebadsize = 53,
-       ns_statscounter_cookiebadtime = 54,
-       ns_statscounter_cookienomatch = 55,
-       ns_statscounter_cookiematch = 56,
-       ns_statscounter_cookienew = 57,
-       ns_statscounter_badcookie = 58,
+       ns_statscounter_nxdomainsynth = 58,
+       ns_statscounter_nodatasynth = 59,
+       ns_statscounter_wildcardsynth = 60,
 
-       ns_statscounter_nxdomainsynth = 59,
-       ns_statscounter_nodatasynth = 60,
-       ns_statscounter_wildcardsynth = 61,
+       ns_statscounter_trystale = 61,
+       ns_statscounter_usedstale = 62,
 
-       ns_statscounter_trystale = 62,
-       ns_statscounter_usedstale = 63,
+       ns_statscounter_prefetch = 63,
+       ns_statscounter_keytagopt = 64,
 
-       ns_statscounter_prefetch = 64,
-       ns_statscounter_keytagopt = 65,
+       ns_statscounter_reclimitdropped = 65,
 
-       ns_statscounter_reclimitdropped = 66,
+       ns_statscounter_updatequota = 66,
+       ns_statscounter_dot = 67,
+       ns_statscounter_doh = 68,
+       ns_statscounter_dohplain = 69,
 
-       ns_statscounter_updatequota = 67,
-       ns_statscounter_dot = 68,
-       ns_statscounter_doh = 69,
-       ns_statscounter_dohplain = 70,
+       ns_statscounter_proxyudp = 70,
+       ns_statscounter_proxytcp = 71,
+       ns_statscounter_proxydot = 72,
+       ns_statscounter_proxydoh = 73,
+       ns_statscounter_proxydohplain = 74,
+       ns_statscounter_encryptedproxydot = 75,
+       ns_statscounter_encryptedproxydoh = 76,
 
-       ns_statscounter_proxyudp = 71,
-       ns_statscounter_proxytcp = 72,
-       ns_statscounter_proxydot = 73,
-       ns_statscounter_proxydoh = 74,
-       ns_statscounter_proxydohplain = 75,
-       ns_statscounter_encryptedproxydot = 76,
-       ns_statscounter_encryptedproxydoh = 77,
-
-       ns_statscounter_max = 78,
+       ns_statscounter_max = 77,
 };
 
 /*%
@@ -133,8 +131,9 @@ enum {
 enum {
        ns_highwater_tcp = 0,
        ns_highwater_recursive = 1,
+       ns_highwater_recursclients = 2,
 
-       ns_highwater_max = 2,
+       ns_highwater_max = 3,
 };
 
 void
index f0ef5c7a4786476aa4c5823cb2753fac9cacfd59..1fa9598a71c4e5358ba06fb4d0dacff8d7bd31ad 100644 (file)
@@ -2609,13 +2609,12 @@ recursionquotatype_attach(ns_client_t *client, bool soft_limit) {
                return result;
        }
 
-       ns_stats_increment(client->manager->sctx->nsstats,
-                          ns_statscounter_recursclients);
-       isc_statscounter_t recurscount = ns_stats_get_counter(
-               client->manager->sctx->nsstats, ns_statscounter_recursclients);
-
-       ns_stats_update_if_greater(client->manager->sctx->nshighwaterstats,
-                                  ns_highwater_recursive, recurscount);
+       isc_statscounter_t recurscount =
+               isc_stats_increment(client->manager->sctx->nshighwaterstats,
+                                   ns_highwater_recursclients) +
+               1;
+       isc_stats_update_if_greater(client->manager->sctx->nshighwaterstats,
+                                   ns_highwater_recursive, recurscount);
 
        return result;
 }
@@ -2633,8 +2632,8 @@ recursionquotatype_attach_soft(ns_client_t *client) {
 static void
 recursionquotatype_detach(ns_client_t *client) {
        isc_quota_release(&client->manager->sctx->recursionquota);
-       ns_stats_decrement(client->manager->sctx->nsstats,
-                          ns_statscounter_recursclients);
+       isc_stats_decrement(client->manager->sctx->nshighwaterstats,
+                           ns_highwater_recursclients);
 }
 
 static void
index 53a4964147c8593cf011e06893aff080e2d9c84e..a2f5e11f4f9a387666f1604463c366fc5db8bf2e 100644 (file)
@@ -933,9 +933,9 @@ run_hookasync_test(const ns__query_hookasync_test_params_t *test) {
                /* Confirm necessary cleanup has been performed. */
                INSIST(qctx->client->query.hookasyncctx == NULL);
                INSIST(qctx->client->inner.state == NS_CLIENTSTATE_WORKING);
-               INSIST(ns_stats_get_counter(
-                              qctx->client->manager->sctx->nsstats,
-                              ns_statscounter_recursclients) == 0);
+               INSIST(isc_stats_get_counter(
+                              qctx->client->manager->sctx->nshighwaterstats,
+                              ns_highwater_recursclients) == 0);
                INSIST(!ISC_LINK_LINKED(qctx->client, inner.rlink));
                if (!test->do_cancel) {
                        /*