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".
fctx->info = isc_mem_strdup(mctx, buf);
if (fctx->info == NULL) {
result = ISC_R_NOMEMORY;
- goto cleanup_counter;
+ goto cleanup_fetch;
}
FCTXTRACE("create");
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);
*/
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;
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));