INSIST(ISC_LIST_EMPTY(fctx->validators));
query = isc_mem_get(fctx->mctx, sizeof(*query));
- *query = (resquery_t){ .mctx = fctx->mctx,
- .options = options,
- .addrinfo = addrinfo,
- .dispatchmgr = res->dispatchmgr };
+ *query = (resquery_t){
+ .mctx = fctx->mctx,
+ .options = options,
+ .addrinfo = addrinfo,
+ .dispatchmgr = res->dispatchmgr,
+ .link = ISC_LINK_INITIALIZER,
+ };
isc_refcount_init(&query->references, 1);
}
fctx_attach(fctx, &query->fctx);
- ISC_LINK_INIT(query, link);
query->magic = QUERY_MAGIC;
if ((query->options & DNS_FETCHOPT_TCP) == 0) {
}
}
+ LOCK(&res->buckets[fctx->bucketnum].lock);
+ if (ISC_LINK_LINKED(query, link)) {
+ atomic_fetch_sub_release(&fctx->nqueries, 1);
+ ISC_LIST_UNLINK(fctx->queries, query, link);
+ }
+ UNLOCK(&res->buckets[fctx->bucketnum].lock);
+
cleanup_dispatch:
fctx_detach(&query->fctx);
}
cleanup_query:
- LOCK(&res->buckets[fctx->bucketnum].lock);
- if (ISC_LINK_LINKED(query, link)) {
- atomic_fetch_sub_release(&fctx->nqueries, 1);
- ISC_LIST_UNLINK(fctx->queries, query, link);
- }
- UNLOCK(&res->buckets[fctx->bucketnum].lock);
-
query->magic = 0;
dns_message_detach(&query->rmessage);
isc_mem_put(fctx->mctx, query, sizeof(*query));