From: W.C.A. Wijngaards Date: Tue, 16 Jun 2026 08:48:17 +0000 (+0200) Subject: - Fix for neater solution to clear log thread id after X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aa09835c9018a52452bbfbd28f847094d303852e;p=thirdparty%2Funbound.git - Fix for neater solution to clear log thread id after worker init failure. Thanks to Qifan Zhang, Palo Alto Networks, for the report. --- diff --git a/daemon/daemon.c b/daemon/daemon.c index ee6b0ab6c..80cb37ff7 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -954,7 +954,6 @@ thread_start(void* arg) #endif if(!worker_init(worker, worker->daemon->cfg, worker->daemon->ports[port_num], 0)) { - log_thread_set(NULL); fatal_exit("Could not initialize thread"); } @@ -1119,7 +1118,6 @@ daemon_fork(struct daemon* daemon) #if defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP) /* in libev the first inited base gets signals */ if(!worker_init(daemon->workers[0], daemon->cfg, daemon->ports[0], 1)) { - log_thread_set(NULL); fatal_exit("Could not initialize main thread"); } #endif @@ -1135,7 +1133,6 @@ daemon_fork(struct daemon* daemon) #if !(defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)) /* libevent has the last inited base get signals (or any base) */ if(!worker_init(daemon->workers[0], daemon->cfg, daemon->ports[0], 1)) { - log_thread_set(NULL); fatal_exit("Could not initialize main thread"); } #endif @@ -1181,7 +1178,6 @@ daemon_cleanup(struct daemon* daemon) /* before stopping main worker, handle signals ourselves, so we don't die on multiple reload signals for example. */ signal_handling_record(); - log_thread_set(NULL); /* clean up caches because * a) RRset IDs will be recycled after a reload, causing collisions * b) validation config can change, thus rrset, msg, keycache clear diff --git a/daemon/worker.c b/daemon/worker.c index 6d922fd92..58ef01944 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -2534,6 +2534,8 @@ worker_delete(struct worker* worker) /* don't touch worker->alloc, as it's maintained in daemon */ regional_destroy(worker->env.scratch); regional_destroy(worker->scratchpad); + /* The thread id can reference this worker's id value, so clear it. */ + log_thread_set(NULL); free(worker); } diff --git a/doc/Changelog b/doc/Changelog index 0ecba8b5d..e9894a09d 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -41,6 +41,9 @@ - Fix that libunbound pipe functions fail with error after an event base is set. Thanks to Qifan Zhang, Palo Alto Networks, for the report. + - Fix for neater solution to clear log thread id after + worker init failure. Thanks to Qifan Zhang, Palo Alto + Networks, for the report. 15 June 2026: Wouter - Fix to add `max-transfer-size` and `max-transfer-time` that