ISC_LIST_UNLINK(client->manager->recursing, client, rlink);
}
UNLOCK(&client->manager->reclock);
+
+ /*
+ * This event is running under a client task, so it's safe to detach
+ * the fetch handle. And it should be done before resuming query
+ * processing below, since that may trigger another recursion or
+ * asynchronous hook event.
+ */
+ isc_nmhandle_detach(&client->fetchhandle);
+
client->state = NS_CLIENTSTATE_WORKING;
if (canceled) {
qctx_destroy(qctx);
isc_mem_put(client->mctx, qctx, sizeof(*qctx));
isc_event_free(&event);
- isc_nmhandle_detach(&client->fetchhandle);
}
isc_result_t
asdata->async = true;
}
} else {
- /* Resume from the completion of recursion */
+ /*
+ * Resume from the completion of async event.
+ * fetchhandle should have been detached so that we can start
+ * another async event or DNS recursive resolution.
+ */
+ INSIST(qctx->client->fetchhandle == NULL);
asdata->async = false;
switch (hookpoint) {
case NS_QUERY_GOT_ANSWER_BEGIN: