]> git.ipfire.org Git - zone-sync.git/commitdiff
main: Shut down if no zone transfers were ever started
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 May 2026 16:23:01 +0000 (16:23 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 May 2026 16:23:01 +0000 (16:23 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
main.c

diff --git a/main.c b/main.c
index 873bb8b3cd13c76b8011b59e70c45b64a5999446..e4f1ff13aff05910eeb07245345964e75c689114 100644 (file)
--- 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) {