]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make sure that recursclient gauge is calculated correctly.
authorWitold Kręcicki <wpk@isc.org>
Tue, 11 Jun 2019 09:32:35 +0000 (11:32 +0200)
committerOndřej Surý <ondrej@sury.org>
Wed, 26 Jun 2019 09:08:44 +0000 (11:08 +0200)
We increase recursclients when we attach to recursion quota,
decrease when we detach. In some cases, when we hit soft
quota, we might attach to quota without increasing recursclients
gauge. We then decrease the gauge when we detach from quota,
and it causes the statistics to underflow.
Fix makes sure that we increase recursclients always when we
succesfully attach to recursion quota.

(cherry picked from commit 24cfee942fdf829914cdfbc77f9e2b8d323a64aa)

lib/ns/query.c

index 223512286db1a6267396bd54a4266aab29da3c63..96c9c7d8fe0b799bbce98498f0ee66fce447baf3 100644 (file)
@@ -2489,12 +2489,18 @@ query_prefetch(ns_client_t *client, dns_name_t *qname,
        if (client->recursionquota == NULL) {
                result = isc_quota_attach(&client->sctx->recursionquota,
                                          &client->recursionquota);
-               if (result == ISC_R_SUCCESS && !client->mortal && !TCP(client))
+               if (result == ISC_R_SUCCESS || result == ISC_R_SOFTQUOTA) {
+                       ns_stats_increment(client->sctx->nsstats,
+                                          ns_statscounter_recursclients);
+               }
+               if (result == ISC_R_SUCCESS && !client->mortal &&
+                   !TCP(client))
+               {
                        result = ns_client_replace(client);
-               if (result != ISC_R_SUCCESS)
+               }
+               if (result != ISC_R_SUCCESS) {
                        return;
-               ns_stats_increment(client->sctx->nsstats,
-                                  ns_statscounter_recursclients);
+               }
        }
 
        tmprdataset = ns_client_newrdataset(client);
@@ -2696,12 +2702,18 @@ query_rpzfetch(ns_client_t *client, dns_name_t *qname, dns_rdatatype_t type) {
        if (client->recursionquota == NULL) {
                result = isc_quota_attach(&client->sctx->recursionquota,
                                          &client->recursionquota);
-               if (result == ISC_R_SUCCESS && !client->mortal && !TCP(client))
+               if (result == ISC_R_SUCCESS || result == ISC_R_SOFTQUOTA) {
+                       ns_stats_increment(client->sctx->nsstats,
+                                          ns_statscounter_recursclients);
+               }
+               if (result == ISC_R_SUCCESS && !client->mortal &&
+                   !TCP(client))
+               {
                        result = ns_client_replace(client);
-               if (result != ISC_R_SUCCESS)
+               }
+               if (result != ISC_R_SUCCESS) {
                        return;
-               ns_stats_increment(client->sctx->nsstats,
-                                  ns_statscounter_recursclients);
+               }
        }
 
        tmprdataset = ns_client_newrdataset(client);
@@ -5722,9 +5734,10 @@ ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname,
        if (client->recursionquota == NULL) {
                result = isc_quota_attach(&client->sctx->recursionquota,
                                          &client->recursionquota);
-
-               ns_stats_increment(client->sctx->nsstats,
-                                  ns_statscounter_recursclients);
+               if (result == ISC_R_SUCCESS || result == ISC_R_SOFTQUOTA) {
+                       ns_stats_increment(client->sctx->nsstats,
+                                          ns_statscounter_recursclients);
+               }
 
                if  (result == ISC_R_SOFTQUOTA) {
                        static atomic_uint_fast32_t last = 0;