]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Revert "Process db callbacks in zone_loaddone() after zone_postload()"
authorAram Sargsyan <aram@isc.org>
Thu, 2 Mar 2023 19:19:55 +0000 (19:19 +0000)
committerAram Sargsyan <aram@isc.org>
Thu, 2 Mar 2023 19:19:55 +0000 (19:19 +0000)
This reverts commit 1254f37584497eac05ed39a5ae01cc0d22d6ea7b.

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

(not cherry picked from commit 593dea871afe903fbff420be0ccb63c85152de4a)

lib/dns/zone.c

index a5b7e1bf08eea98a32a3c1ad81150ab807df2840..702f712160bf8b87aa55e9bae49ea109ac1e5e06 100644 (file)
@@ -17798,6 +17798,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.
         */
@@ -17816,14 +17823,10 @@ 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);
        zonemgr_putio(&zone->readio);
        DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_LOADING);
+       zone_idetach(&load->callbacks.zone);
        /*
         * Leave the zone frozen if the reload fails.
         */
@@ -17840,14 +17843,7 @@ 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);