From: Alessio Podda Date: Wed, 25 Mar 2026 12:12:41 +0000 (+0100) Subject: Move ns_highwater_recursclients to highwater stats X-Git-Tag: v9.21.21~9^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70b65648ac694ac25192be4c60cf01657f575507;p=thirdparty%2Fbind9.git Move ns_highwater_recursclients to highwater stats 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. --- diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index 17b33d7cf81..91642857f6e 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -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); diff --git a/lib/ns/include/ns/stats.h b/lib/ns/include/ns/stats.h index c242f2c19c6..bcc4d789c68 100644 --- a/lib/ns/include/ns/stats.h +++ b/lib/ns/include/ns/stats.h @@ -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 diff --git a/lib/ns/query.c b/lib/ns/query.c index f0ef5c7a478..1fa9598a71c 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -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 diff --git a/tests/ns/query_test.c b/tests/ns/query_test.c index 53a4964147c..a2f5e11f4f9 100644 --- a/tests/ns/query_test.c +++ b/tests/ns/query_test.c @@ -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) { /*