]> 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)
committerEvan Hunt <each@isc.org>
Wed, 7 Aug 2024 22:36:14 +0000 (15:36 -0700)
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)

lib/dns/resolver.c

index 83ae50b782ad3558a94122623ab06eeb0aecd9a9..cdb3c6e78574d14cc17fd03e2488836c55ec0668 100644 (file)
@@ -4809,16 +4809,6 @@ fctx_create(dns_resolver_t *res, isc_task_t *task, const dns_name_t *name,
 
        dns_resolver_attach(res, &fctx->res);
 
-       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". FCTXTRACE won't work until this is done.
@@ -4831,6 +4821,24 @@ fctx_create(dns_resolver_t *res, isc_task_t *task, const dns_name_t *name,
 
        FCTXTRACE("create");
 
+       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_fetch;
+               }
+               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_refcount_init(&fctx->references, 1);
 
        ISC_LIST_INIT(fctx->queries);