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);
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) {
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) {