]> 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>
Thu, 29 Jan 2026 08:13:02 +0000 (09:13 +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.

(cherry picked from commit 399f0c191a9bfb1d2a10ff7f51d3a42af5671d16)

lib/dns/xfrin.c

index 19395907bf02ec779fb3899de04f74390af070ed..0443a688d1bbc57d311b27a7596ecbf75d9782e1 100644 (file)
@@ -78,6 +78,8 @@ typedef enum {
  * Incoming zone transfer context.
  */
 
+typedef struct dns_ixfr dns_ixfr_t;
+
 struct dns_xfrin {
        unsigned int magic;
        isc_mem_t *mctx;
@@ -170,7 +172,7 @@ struct dns_xfrin {
         */
        dns_rdatacallbacks_t axfr;
 
-       struct {
+       struct dns_ixfr {
                uint32_t request_serial;
                uint32_t current_serial;
                dns_journal_t *journal;
@@ -485,24 +487,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;
@@ -513,7 +513,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) {
@@ -526,12 +526,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;
 }