]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
detach fetchhandle before resume query processing
authorJINMEI Tatuya <jtatuya@infoblox.com>
Sat, 12 Dec 2020 05:44:54 +0000 (21:44 -0800)
committerEvan Hunt <each@isc.org>
Wed, 6 Jan 2021 21:14:13 +0000 (13:14 -0800)
otherwise, another hook async event or DNS recursion would
trigger an assertion failure.

lib/ns/query.c
lib/ns/tests/query_test.c

index 10a08ce4e00d728bf384089863824ec9f965756d..bbaf1c91b1537344e0e56697c44e605148469dcf 100644 (file)
@@ -6349,6 +6349,15 @@ query_hookresume(isc_task_t *task, isc_event_t *event) {
                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) {
@@ -6450,7 +6459,6 @@ query_hookresume(isc_task_t *task, isc_event_t *event) {
        qctx_destroy(qctx);
        isc_mem_put(client->mctx, qctx, sizeof(*qctx));
        isc_event_free(&event);
-       isc_nmhandle_detach(&client->fetchhandle);
 }
 
 isc_result_t
index 0f6a598c5bea82756d7a7988c3e6bb3bfda74fbf..d5943bc7751c53079d4a3d4fa77c6502588b956a 100644 (file)
@@ -717,7 +717,12 @@ hook_recurse_common(void *arg, void *data, isc_result_t *resultp,
                        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: