From be34b1c53526e80c683ab9c3a057ac0bed2d3da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 3 Mar 2022 14:44:28 +0100 Subject: [PATCH] Reorder the nsupdate shutdown code to shutdown managers early 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 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 8423f5aa93..b0af713923 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -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