]> git.ipfire.org Git - zone-sync.git/commitdiff
main: Store the XFR object with the zone context and clean it up
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 May 2026 16:58:09 +0000 (16:58 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 May 2026 16:58:09 +0000 (16:58 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
main.c

diff --git a/main.c b/main.c
index 7bf161341b775c99c419b05fc23c5038c681b0db..32cd52f95861c0631b4855e415968a04827856a7 100644 (file)
--- a/main.c
+++ b/main.c
@@ -246,7 +246,11 @@ static void zone_done(dns_zone_t* z) {
        // Fetch the zone
        zone_ctx* zone = find_zone(z);
        if (!zone)
-               return ;
+               return;
+
+       // Detach the XFR object
+       if (zone->xfrin)
+               dns_xfrin_detach(&zone->xfrin);
 
        // Release the zone from the manager
        dns_zonemgr_releasezone(ctx.zonemgr, zone->zone);
@@ -298,8 +302,8 @@ static void transfer_done(dns_zone_t* zone, uint32_t* expireopt, isc_result_t re
        zone_done(zone);
 }
 
-static int do_transfer(dns_zone_t* zone, uint32_t serial) {
-       dns_xfrin_t* xfrin = NULL;
+
+static int do_transfer(zone_ctx* zone, uint32_t serial) {
        dns_rdatatype_t xfrtype;
        int r;
 
@@ -315,13 +319,13 @@ static int do_transfer(dns_zone_t* zone, uint32_t serial) {
        }
 
        // Require at least 10 kBit/s to be transmitted over 5 minutes
-       dns_zone_setminxfrratein(zone, 10240, 300);
+       dns_zone_setminxfrratein(zone->zone, 10240, 300);
 
-       dns_xfrin_create(zone, xfrtype, &ctx.primary_address, &ctx.source_address, NULL,
-               DNS_TRANSPORT_NONE, ctx.transport, ctx.tlsctx_cache, ctx.memctx, &xfrin);
+       dns_xfrin_create(zone->zone, xfrtype, &ctx.primary_address, &ctx.source_address, NULL,
+               DNS_TRANSPORT_NONE, ctx.transport, ctx.tlsctx_cache, ctx.memctx, &zone->xfrin);
 
        // Start the transfer
-       r = dns_xfrin_start(xfrin, transfer_done);
+       r = dns_xfrin_start(zone->xfrin, transfer_done);
        switch (r) {
                case ISC_R_SUCCESS:
                        break;
@@ -335,7 +339,7 @@ static int do_transfer(dns_zone_t* zone, uint32_t serial) {
        return r;
 
 ERROR:
-       zone_done(zone);
+       zone_done(zone->zone);
        return r;
 }
 
@@ -364,7 +368,7 @@ static isc_result_t zone_loaded(void* data) {
        }
 
        // Initiate the transfer
-       return do_transfer(zone->zone, serial);
+       return do_transfer(zone, serial);
 
 ERROR:
        // Destroy the zone