]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix for neater solution to clear log thread id after
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 16 Jun 2026 08:48:17 +0000 (10:48 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 16 Jun 2026 08:48:17 +0000 (10:48 +0200)
  worker init failure. Thanks to Qifan Zhang, Palo Alto
  Networks, for the report.

daemon/daemon.c
daemon/worker.c
doc/Changelog

index ee6b0ab6cd849440578af67c7a2ea85cf708a2ec..80cb37ff755f33cf89f5589eb0eb852c2ac2339c 100644 (file)
@@ -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
index 6d922fd9255406a9b2aea88b2ee7fce40243a038..58ef019445bfb0705155db5847be2f82f77a2067 100644 (file)
@@ -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);
 }
 
index 0ecba8b5d0a1b658c5d4389e879c392890d41abf..e9894a09d562fc2d7720e3bf9632c0b060b0d8b0 100644 (file)
@@ -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