]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Clean up ixfr transaction API
authorAlessio Podda <alessio@isc.org>
Sat, 25 Oct 2025 09:01:27 +0000 (11:01 +0200)
committerAlessio Podda <alessio@isc.org>
Tue, 9 Dec 2025 11:55:10 +0000 (12:55 +0100)
Make the API tighter. The idea of this commit is to highlight the
distinction between a database transaction and a journal transaction,
and ensure we run dns_zone_verifydb on error.

Done to simplify a later refactor.

lib/dns/xfrin.c

index 60bee118064228e6aaf14eaeab16cd9f69ce43bf..f4ef175d40ad5050deb4d84d5f2feaf1b9b3f19a 100644 (file)
@@ -80,6 +80,8 @@ typedef enum {
  * Incoming zone transfer context.
  */
 
+typedef struct dns_ixfr dns_ixfr_t;
+
 struct dns_xfrin {
        unsigned int magic;
        isc_mem_t *mctx;
@@ -172,7 +174,7 @@ struct dns_xfrin {
         */
        dns_rdatacallbacks_t axfr;
 
-       struct {
+       struct dns_ixfr {
                uint32_t diffs;
                uint32_t maxdiffs;
                uint32_t request_serial;
@@ -488,24 +490,22 @@ cleanup:
 }
 
 static isc_result_t
-ixfr_begin_transaction(dns_xfrin_t *xfr) {
+ixfr_begin_transaction(dns_ixfr_t *ixfr) {
        isc_result_t result = ISC_R_SUCCESS;
 
-       if (xfr->ixfr.journal != NULL) {
-               CHECK(dns_journal_begin_transaction(xfr->ixfr.journal));
+       if (ixfr->journal != NULL) {
+               CHECK(dns_journal_begin_transaction(ixfr->journal));
        }
 cleanup:
        return result;
 }
 
 static isc_result_t
-ixfr_end_transaction(dns_xfrin_t *xfr) {
+ixfr_end_transaction(dns_ixfr_t *ixfr) {
        isc_result_t result = ISC_R_SUCCESS;
-
-       CHECK(dns_zone_verifydb(xfr->zone, xfr->db, xfr->ver));
        /* XXX enter ready-to-commit state here */
-       if (xfr->ixfr.journal != NULL) {
-               CHECK(dns_journal_commit(xfr->ixfr.journal));
+       if (ixfr->journal != NULL) {
+               CHECK(dns_journal_commit(ixfr->journal));
        }
 cleanup:
        return result;
@@ -516,7 +516,7 @@ ixfr_apply_one(dns_xfrin_t *xfr, ixfr_apply_data_t *data) {
        isc_result_t result = ISC_R_SUCCESS;
        uint64_t records;
 
-       CHECK(ixfr_begin_transaction(xfr));
+       CHECK(ixfr_begin_transaction(&xfr->ixfr));
 
        CHECK(dns_diff_apply(&data->diff, xfr->db, xfr->ver));
        if (xfr->maxrecords != 0U) {
@@ -529,12 +529,14 @@ ixfr_apply_one(dns_xfrin_t *xfr, ixfr_apply_data_t *data) {
                CHECK(dns_journal_writediff(xfr->ixfr.journal, &data->diff));
        }
 
-       result = ixfr_end_transaction(xfr);
+       CHECK(dns_zone_verifydb(xfr->zone, xfr->db, xfr->ver));
+
+       result = ixfr_end_transaction(&xfr->ixfr);
 
        return result;
 cleanup:
        /* We need to end the transaction, but keep the previous error */
-       (void)ixfr_end_transaction(xfr);
+       (void)ixfr_end_transaction(&xfr->ixfr);
 
        return result;
 }