mctx = res->buckets[bucketnum].mctx;
fctx = isc_mem_get(mctx, sizeof(*fctx));
- 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".
dns_rdataset_init(&fctx->qminrrset);
dns_name_init(&fctx->qmindcname, NULL);
isc_stdtime_get(&fctx->now);
+ 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_nameservers;
+ }
+ 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);
findoptions, true, true,
&fctx->nameservers, NULL);
if (result != ISC_R_SUCCESS) {
- goto cleanup_nameservers;
+ goto cleanup_counter;
}
dns_name_dup(fname, mctx, &fctx->domain);
dns_name_free(&fctx->qmindcname, mctx);
}
+cleanup_counter:
+ isc_counter_detach(&fctx->qc);
+
cleanup_nameservers:
if (dns_rdataset_isassociated(&fctx->nameservers)) {
dns_rdataset_disassociate(&fctx->nameservers);
dns_name_free(&fctx->name, mctx);
dns_name_free(&fctx->qminname, mctx);
isc_mem_free(mctx, fctx->info);
- isc_counter_detach(&fctx->qc);
-
-cleanup_fetch:
isc_mem_put(mctx, fctx, sizeof(*fctx));
return (result);