From: Michael Tremer Date: Mon, 18 May 2026 16:55:33 +0000 (+0000) Subject: main: Fetch the zone context on cleanup X-Git-Tag: 0.0.1~14 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=7ffd352f5567bf2cd9d7d27379c5c34f9545efd0;p=zone-sync.git main: Fetch the zone context on cleanup Signed-off-by: Michael Tremer --- diff --git a/main.c b/main.c index ccd728e..7bf1613 100644 --- 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--;