From: Michael Tremer Date: Mon, 18 May 2026 16:23:01 +0000 (+0000) Subject: main: Shut down if no zone transfers were ever started X-Git-Tag: 0.0.1~17 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=fcf22741cca965295817fe438604996519ff3b47;p=zone-sync.git main: Shut down if no zone transfers were ever started Signed-off-by: Michael Tremer --- diff --git a/main.c b/main.c index 873bb8b..e4f1ff1 100644 --- a/main.c +++ b/main.c @@ -214,6 +214,16 @@ static isc_result_t dns_name_from_string(dns_name_t** name, const char *text) { return 0; } +static void maybe_shutdown(void) { + // Don't shut down if there is something left running + if (ctx.running) + return; + + DEBUG("Shutting down...\n"); + + isc_loopmgr_shutdown(ctx.loopmgr); +} + static void zone_done(dns_zone_t* zone) { // Release the zone from the manager dns_zonemgr_releasezone(ctx.zonemgr, zone); @@ -222,8 +232,7 @@ static void zone_done(dns_zone_t* zone) { dns_zone_detach(&zone); // Terminate if we are all done - if (!--ctx.running) - isc_loopmgr_shutdown(ctx.loopmgr); + maybe_shutdown(); } static void transfer_done(dns_zone_t* zone, uint32_t* expireopt, isc_result_t result) { @@ -501,12 +510,12 @@ static void run_loop(void* data) { for (unsigned int i = 0; i < ctx.num_zones; i++) do_zone(ctx.zones[i]); +ERROR: + // Potentially shut down if there is nothing to do + maybe_shutdown(); + // Done return; - -ERROR: - // Shutdown the event loop on error - isc_loopmgr_shutdown(ctx.loopmgr); } static void destroy_loop(void* data) {