]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
isc_loopmgr_pause was called inappropriately
authorMark Andrews <marka@isc.org>
Tue, 11 Apr 2023 05:32:51 +0000 (15:32 +1000)
committerMark Andrews <marka@isc.org>
Tue, 18 Apr 2023 00:28:36 +0000 (00:28 +0000)
isc_loopmgr_pause can't be called before isc_loopmgr_run is
called as the thread ids are not yet valid.  If there is a
fatal error before isc_loopmgr_run is run then don't call
isc_loopmgr_pause.

bin/named/include/named/globals.h
bin/named/main.c
bin/named/server.c

index 4f64c13a133570fb934d012b9d5751cf1dee3e84..03e35f2cd4b9e075ac0cb082ac673cee62e523e8 100644 (file)
@@ -53,6 +53,7 @@ EXTERN unsigned int named_g_cpus            INIT(0);
 EXTERN unsigned int named_g_udpdisp          INIT(0);
 EXTERN isc_loop_t *named_g_mainloop          INIT(NULL);
 EXTERN isc_loopmgr_t *named_g_loopmgr        INIT(NULL);
+EXTERN bool named_g_loopmgr_running          INIT(false);
 EXTERN dns_dispatchmgr_t *named_g_dispatchmgr INIT(NULL);
 EXTERN unsigned int named_g_cpus_detected     INIT(1);
 
index 6d73b338bc439eb925940492a31369461db6f46a..5372b902fd368ce0234d19dafc3bc455a505202c 100644 (file)
@@ -1506,6 +1506,10 @@ main(int argc, char *argv[]) {
         */
        isc_signal_start(named_g_server->sighup);
 
+       /*
+        * Pause the loop manager in fatal.
+        */
+       named_g_loopmgr_running = true;
        isc_loopmgr_run(named_g_loopmgr);
 
 #ifdef HAVE_LIBSCF
index 8e3ba56205df2475e1471d2f6b603f6f01c521a3..a13c9c7a4d46c9b4c676cabceddb4e8d2dccdcf0 100644 (file)
@@ -10286,7 +10286,9 @@ named_server_destroy(named_server_t **serverp) {
 
 static void
 fatal(const char *msg, isc_result_t result) {
-       isc_loopmgr_pause(named_g_loopmgr);
+       if (named_g_loopmgr_running) {
+               isc_loopmgr_pause(named_g_loopmgr);
+       }
        isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
                      NAMED_LOGMODULE_SERVER, ISC_LOG_CRITICAL, "%s: %s", msg,
                      isc_result_totext(result));