]> git.ipfire.org Git - zone-sync.git/commitdiff
main: Fetch the zone context on cleanup
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 May 2026 16:55:33 +0000 (16:55 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 May 2026 16:55:33 +0000 (16:55 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
main.c

diff --git a/main.c b/main.c
index ccd728ec7c1d30f3070be048f843df4ae1875756..7bf161341b775c99c419b05fc23c5038c681b0db 100644 (file)
--- a/main.c
+++ b/main.c
@@ -222,6 +222,16 @@ static isc_result_t dns_name_from_string(dns_name_t** name, const char *text) {
        return 0;
 }
 
+// Returns the zone context for a given zone
+static zone_ctx* find_zone(dns_zone_t* z) {
+       for (unsigned int i = 0; i < ctx.num_zones; i++) {
+               if (ctx.zones[i].zone == z)
+                       return &ctx.zones[i];
+       }
+
+       return NULL;
+}
+
 static void maybe_shutdown(void) {
        // Don't shut down if there is something left running
        if (ctx.running)
@@ -232,12 +242,17 @@ static void maybe_shutdown(void) {
        isc_loopmgr_shutdown(ctx.loopmgr);
 }
 
-static void zone_done(dns_zone_t* zone) {
+static void zone_done(dns_zone_t* z) {
+       // Fetch the zone
+       zone_ctx* zone = find_zone(z);
+       if (!zone)
+               return ;
+
        // Release the zone from the manager
-       dns_zonemgr_releasezone(ctx.zonemgr, zone);
+       dns_zonemgr_releasezone(ctx.zonemgr, zone->zone);
 
        // Free the zone
-       dns_zone_detach(&zone);
+       dns_zone_detach(&zone->zone);
 
        // Decrement the number of running zones
        ctx.running--;