]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Revert "Process db callbacks in zone_loaddone() after zone_postload()"
authorAram Sargsyan <aram@isc.org>
Wed, 1 Mar 2023 17:26:41 +0000 (17:26 +0000)
committerAram Sargsyan <aram@isc.org>
Wed, 1 Mar 2023 17:26:41 +0000 (17:26 +0000)
This reverts commit ed268b46f11706bde3da68bd2a4b45752350f736.

The commit introduced a data race, because dns_db_endload() is called
after unfreezing the zone.

lib/dns/zone.c

index 544b502a4c3f6f33d70a0d61d601228ebae06c0b..bb3bcaa79bcf0fd0af642443bea7b84ade3df435 100644 (file)
@@ -17244,6 +17244,13 @@ 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.
         */
@@ -17262,13 +17269,9 @@ again:
                        goto again;
                }
        }
-       tresult = zone_postload(zone, load->db, load->loadtime, result);
-       if (tresult != ISC_R_SUCCESS &&
-           (result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE))
-       {
-               result = tresult;
-       }
+       (void)zone_postload(zone, load->db, load->loadtime, result);
        DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_LOADING);
+       zone_idetach(&load->callbacks.zone);
        /*
         * Leave the zone frozen if the reload fails.
         */
@@ -17285,12 +17288,6 @@ again:
        }
        UNLOCK_ZONE(zone);
 
-       (void)dns_db_endload(load->db, &load->callbacks);
-
-       LOCK_ZONE(zone);
-       zone_idetach(&load->callbacks.zone);
-       UNLOCK_ZONE(zone);
-
        dns_db_detach(&load->db);
        if (zone->loadctx != NULL) {
                dns_loadctx_detach(&zone->loadctx);