]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Reorder the nsupdate shutdown code to shutdown managers early
authorOndřej Surý <ondrej@isc.org>
Thu, 3 Mar 2022 13:44:28 +0000 (14:44 +0100)
committerOndřej Surý <ondrej@isc.org>
Fri, 4 Mar 2022 12:47:59 +0000 (13:47 +0100)
If the dns_request send callback is delayed, the dst API would get
deinitialized and then the detach from the tsig key would cause an
assertion failure.

Shutdown the isc_managers early, and only then dereference the dst
objects when cleaning up the resources used by nsupdate.

bin/nsupdate/nsupdate.c

index 8423f5aa93ebcd9770524f471de5f3c185ba3b90..b0af713923a8053708d7148d533d840b559e28ee 100644 (file)
@@ -719,12 +719,6 @@ doshutdown(void) {
                dns_message_detach(&updatemsg);
        }
 
-       if (is_dst_up) {
-               ddebug("Destroy DST lib");
-               dst_lib_destroy();
-               is_dst_up = false;
-       }
-
        ddebug("Destroying request manager");
        dns_requestmgr_detach(&requestmgr);
 
@@ -3305,6 +3299,9 @@ cleanup(void) {
        }
        UNLOCK(&answer_lock);
 
+       ddebug("Shutting down managers");
+       isc_managers_destroy(&netmgr, &taskmgr, NULL);
+
 #if HAVE_GSSAPI
        if (tsigkey != NULL) {
                ddebug("detach tsigkey x%p", tsigkey);
@@ -3320,9 +3317,6 @@ cleanup(void) {
                dst_key_free(&sig0key);
        }
 
-       ddebug("Shutting down managers");
-       isc_managers_destroy(&netmgr, &taskmgr, NULL);
-
        ddebug("Destroying event");
        isc_event_free(&global_event);
 
@@ -3356,6 +3350,12 @@ cleanup(void) {
        isc_mem_destroy(&gmctx);
 
        isc_mutex_destroy(&answer_lock);
+
+       if (is_dst_up) {
+               ddebug("Destroy DST lib");
+               dst_lib_destroy();
+               is_dst_up = false;
+       }
 }
 
 static void