]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Process db callbacks in zone_loaddone() after zone_postload()
authorAram Sargsyan <aram@isc.org>
Thu, 26 Jan 2023 19:08:19 +0000 (19:08 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Tue, 28 Feb 2023 13:47:18 +0000 (13:47 +0000)
The zone_postload() function can fail and unregister the callbacks.

Call dns_db_endload() only after calling zone_postload() to make
sure that the registered update-notify callbacks are not called
when the zone loading has failed during zone_postload().

Also, don't ignore the return value of zone_postload().

(cherry picked from commit ed268b46f11706bde3da68bd2a4b45752350f736)

lib/dns/zone.c

index c9bb34515637b445c176137f897aa8e0a1b0b12b..ba130b959e78abf504a9f8bdca7d6625e98e1ab5 100644 (file)
@@ -17843,13 +17843,6 @@ zone_loaddone(void *arg, isc_result_t result) {
                dns_zone_catz_disable_db(zone, load->db);
        }
 
-       tresult = dns_db_endload(load->db, &load->callbacks);
-       if (tresult != ISC_R_SUCCESS &&
-           (result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE))
-       {
-               result = tresult;
-       }
-
        /*
         * Lock hierarchy: zmgr, zone, raw.
         */
@@ -17868,10 +17861,14 @@ again:
                        goto again;
                }
        }
-       (void)zone_postload(zone, load->db, load->loadtime, result);
+       tresult = zone_postload(zone, load->db, load->loadtime, result);
+       if (tresult != ISC_R_SUCCESS &&
+           (result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE))
+       {
+               result = tresult;
+       }
        zonemgr_putio(&zone->readio);
        DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_LOADING);
-       zone_idetach(&load->callbacks.zone);
        /*
         * Leave the zone frozen if the reload fails.
         */
@@ -17888,7 +17885,14 @@ again:
        }
        UNLOCK_ZONE(zone);
 
+       (void)dns_db_endload(load->db, &load->callbacks);
+
+       LOCK_ZONE(zone);
+       zone_idetach(&load->callbacks.zone);
+       UNLOCK_ZONE(zone);
+
        load->magic = 0;
+
        dns_db_detach(&load->db);
        if (load->zone->lctx != NULL) {
                dns_loadctx_detach(&load->zone->lctx);