]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add debug logging when creating or attaching to a query counter
authorEvan Hunt <each@isc.org>
Tue, 25 Jun 2024 18:02:49 +0000 (11:02 -0700)
committerOndřej Surý <ondrej@isc.org>
Tue, 20 Aug 2024 17:34:46 +0000 (17:34 +0000)
fctx_create() now logs at debug level 9 when the fctx attaches
to an existing counter or creates a new one.

(cherry picked from commit 825f3d68c5b041b53f13a8c5b4dc431ca9b5887f)
(cherry picked from commit 14bce7e27582f97d2e5be43a8e88df84e241c5cb)

lib/dns/resolver.c

index c737175d3a9758a4e412b0dde22c710fe2af1137..41e0aa5b5a9b3cdede0702b62e4e399b0a369dc9 100644 (file)
@@ -4369,16 +4369,6 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
        if (fctx == NULL)
                return (ISC_R_NOMEMORY);
 
-       fctx->qc = NULL;
-       if (qc != NULL) {
-               isc_counter_attach(qc, &fctx->qc);
-       } else {
-               result = isc_counter_create(res->mctx,
-                                           res->maxqueries, &fctx->qc);
-               if (result != ISC_R_SUCCESS)
-                       goto cleanup_fetch;
-       }
-
        /*
         * Make fctx->info point to a copy of a formatted string
         * "name/type".
@@ -4390,7 +4380,7 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
        fctx->info = isc_mem_strdup(mctx, buf);
        if (fctx->info == NULL) {
                result = ISC_R_NOMEMORY;
-               goto cleanup_counter;
+               goto cleanup_fetch;
        }
 
        FCTXTRACE("create");
@@ -4416,6 +4406,26 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
        fctx->want_shutdown = false;
        fctx->cloned = false;
        fctx->depth = depth;
+       fctx->qc = NULL;
+
+       if (qc != NULL) {
+               isc_counter_attach(qc, &fctx->qc);
+               isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER,
+                             DNS_LOGMODULE_RESOLVER, ISC_LOG_DEBUG(9),
+                             "fctx %p(%s): attached to counter %p (%d)", fctx,
+                             fctx->info, fctx->qc, isc_counter_used(fctx->qc));
+       } else {
+               result = isc_counter_create(res->mctx, res->maxqueries,
+                                           &fctx->qc);
+               if (result != ISC_R_SUCCESS) {
+                       goto cleanup_name;
+               }
+               isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER,
+                             DNS_LOGMODULE_RESOLVER, ISC_LOG_DEBUG(9),
+                             "fctx %p(%s): created counter %p", fctx,
+                             fctx->info, fctx->qc);
+       }
+
        ISC_LIST_INIT(fctx->queries);
        ISC_LIST_INIT(fctx->finds);
        ISC_LIST_INIT(fctx->altfinds);
@@ -4529,12 +4539,12 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
                         */
                        result = dns_name_dup(domain, mctx, &fctx->domain);
                        if (result != ISC_R_SUCCESS)
-                               goto cleanup_name;
+                               goto cleanup_counter;
                }
        } else {
                result = dns_name_dup(domain, mctx, &fctx->domain);
                if (result != ISC_R_SUCCESS)
-                       goto cleanup_name;
+                       goto cleanup_counter;
                dns_rdataset_clone(nameservers, &fctx->nameservers);
                fctx->ns_ttl = fctx->nameservers.ttl;
                fctx->ns_ttl_ok = true;
@@ -4637,15 +4647,15 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
        if (dns_rdataset_isassociated(&fctx->nameservers))
                dns_rdataset_disassociate(&fctx->nameservers);
 
+ cleanup_counter:
+       isc_counter_detach(&fctx->qc);
+
  cleanup_name:
        dns_name_free(&fctx->name, mctx);
 
  cleanup_info:
        isc_mem_free(mctx, fctx->info);
 
- cleanup_counter:
-       isc_counter_detach(&fctx->qc);
-
  cleanup_fetch:
        isc_mem_put(mctx, fctx, sizeof(*fctx));