]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Stop processing catalog zone changes when shutting down
authorMark Andrews <marka@isc.org>
Tue, 7 May 2024 06:48:17 +0000 (16:48 +1000)
committerMark Andrews <marka@isc.org>
Wed, 8 May 2024 22:17:44 +0000 (08:17 +1000)
Abandon catz_addmodzone_cb  and catz_delzone_cb processing if the
loop is shutting down.

bin/named/server.c
lib/isc/include/isc/loop.h
lib/isc/loop.c

index cf852657c051dfb9b116ef4c2d50ab8a818e444b..908eb4de5dde05a1f5cb3d69540a6ce5ce3b6a3b 100644 (file)
@@ -2656,6 +2656,10 @@ catz_addmodzone_cb(void *arg) {
        ns_cfgctx_t *cfg = NULL;
        dns_zone_t *zone = NULL;
 
+       if (isc_loop_shuttingdown(isc_loop_get(named_g_loopmgr, isc_tid()))) {
+               goto cleanup;
+       }
+
        cfg = (ns_cfgctx_t *)cz->view->new_zone_config;
        if (cfg == NULL) {
                isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
@@ -2865,6 +2869,10 @@ catz_delzone_cb(void *arg) {
        char cname[DNS_NAME_FORMATSIZE];
        const char *file = NULL;
 
+       if (isc_loop_shuttingdown(isc_loop_get(named_g_loopmgr, isc_tid()))) {
+               goto cleanup;
+       }
+
        isc_loopmgr_pause(named_g_loopmgr);
 
        dns_name_format(dns_catz_entry_getname(cz->entry), cname,
@@ -2877,7 +2885,7 @@ catz_delzone_cb(void *arg) {
                              "catz: catz_delzone_cb: "
                              "zone '%s' not found",
                              cname);
-               goto cleanup;
+               goto resume;
        }
 
        if (!dns_zone_getadded(zone)) {
@@ -2886,7 +2894,7 @@ catz_delzone_cb(void *arg) {
                              "catz: catz_delzone_cb: "
                              "zone '%s' is not a dynamically added zone",
                              cname);
-               goto cleanup;
+               goto resume;
        }
 
        if (dns_zone_get_parentcatz(zone) != cz->origin) {
@@ -2895,7 +2903,7 @@ catz_delzone_cb(void *arg) {
                              "catz: catz_delzone_cb: zone "
                              "'%s' exists in multiple catalog zones",
                              cname);
-               goto cleanup;
+               goto resume;
        }
 
        /* Stop answering for this zone */
@@ -2904,7 +2912,9 @@ catz_delzone_cb(void *arg) {
                dns_zone_unload(zone);
        }
 
-       CHECK(dns_view_delzone(cz->view, zone));
+       if (dns_view_delzone(cz->view, zone) != ISC_R_SUCCESS) {
+               goto resume;
+       }
        file = dns_zone_getfile(zone);
        if (file != NULL) {
                isc_file_remove(file);
@@ -2919,8 +2929,9 @@ catz_delzone_cb(void *arg) {
                      "catz: catz_delzone_cb: "
                      "zone '%s' deleted",
                      cname);
-cleanup:
+resume:
        isc_loopmgr_resume(named_g_loopmgr);
+cleanup:
        if (zone != NULL) {
                dns_zone_detach(&zone);
        }
index e7745323034cf77318de85106de58c0cc5ab237b..f02c0925d62ca338e84b4e5604baf04233bc06b6 100644 (file)
@@ -215,4 +215,14 @@ isc_loop_now(isc_loop_t *loop);
  *
  * \li 'loop' is a valid loop.
  */
+
+bool
+isc_loop_shuttingdown(isc_loop_t *loop);
+/*%<
+ * Returns whether the loop is shutting down.
+ *
+ * Requires:
+ *
+ * \li 'loop' is a valid loop and the loop tid matches the current tid.
+ */
 ISC_LANG_ENDDECLS
index 4aef8f2aadd53e8f202374a683e25411d0a6233c..5cad59e2e6c106c0e5a82f6b67b9eff43c4c1553 100644 (file)
@@ -616,3 +616,11 @@ isc_loop_now(isc_loop_t *loop) {
 
        return (t);
 }
+
+bool
+isc_loop_shuttingdown(isc_loop_t *loop) {
+       REQUIRE(VALID_LOOP(loop));
+       REQUIRE(loop->tid == isc_tid());
+
+       return (loop->shuttingdown);
+}