ns_client_t *client; /* client object */
bool detach_client; /* client needs detaching */
+ bool async; /* asynchronous hook running */
dns_fetchresponse_t *fresp; /* recursion response */
if (qctx->db != NULL && qctx->node != NULL) {
dns_db_detachnode(qctx->db, &qctx->node);
}
+ if (qctx->client != NULL && qctx->client->query.gluedb != NULL) {
+ dns_db_detach(&qctx->client->query.gluedb);
+ }
}
/*%
goto cleanup_and_detach_from_quota;
}
+ /* Record that an asynchronous copy of the qctx has been started */
+ qctx->async = true;
+
/*
* Typically the runasync() function will trigger recursion, but
* there is no need to set NS_QUERYATTR_RECURSING. The calling hook
qctx_clean(qctx);
qctx_freedata(qctx);
- if (qctx->client->query.gluedb != NULL) {
- dns_db_detach(&qctx->client->query.gluedb);
- }
-
/*
* Clear the AA bit if we're not authoritative.
*/
return qctx->result;
cleanup:
+ /*
+ * We'd only get here if one of the hooks above
+ * (NS_QUERY_DONE_BEGIN or NS_QUERY_DONE_SEND) returned
+ * NS_HOOK_RETURN. Some housekeeping may be needed.
+ */
+ qctx_clean(qctx);
+ qctx_freedata(qctx);
+ if (!qctx->async) {
+ qctx->detach_client = true;
+ query_error(qctx->client, DNS_R_SERVFAIL, __LINE__);
+ }
return result;
}