From: Michael Tremer Date: Mon, 11 May 2026 14:14:08 +0000 (+0000) Subject: main: Add a counter to terminate the event loop X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f20c4fcaa5dd6093f60063462774308ab650349f;p=zone-sync.git main: Add a counter to terminate the event loop Signed-off-by: Michael Tremer --- diff --git a/main.c b/main.c index f712534..187ffc8 100644 --- a/main.c +++ b/main.c @@ -48,6 +48,9 @@ typedef struct ctx { const char** zones; unsigned int num_zones; + // How many transfers are running? + unsigned int running; + // Memory Context isc_mem_t* memctx; @@ -157,6 +160,18 @@ static void setup_logging(void) { isc_log_setcontext(ctx.log); } +static void zone_done(dns_zone_t* zone) { + // Release the zone from the manager + dns_zonemgr_releasezone(ctx.zonemgr, zone); + + // Free the zone + dns_zone_detach(&zone); + + // Terminate if we are all done + if (!--ctx.running) + isc_loopmgr_shutdown(ctx.loopmgr); +} + static void transfer_done(dns_zone_t* zone, uint32_t* serial, isc_result_t result) { int r; @@ -180,11 +195,8 @@ static void transfer_done(dns_zone_t* zone, uint32_t* serial, isc_result_t resul break; } - // Release the zone from the manager - dns_zonemgr_releasezone(ctx.zonemgr, zone); - - // Free the zone - dns_zone_detach(&zone); + // We are done + zone_done(zone); } static int do_transfer(dns_zone_t* zone, uint32_t serial) { @@ -260,6 +272,9 @@ static void do_zone(const char* name) { char path[PATH_MAX]; int r; + // Increment counter + ctx.running++; + // Create the origin origin = dns_fixedname_initname(&fixed);