Clean up ixfr transaction API

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 399f0c191a)
This commit is contained in:
Alessio Podda 2025-10-25 11:01:27 +02:00
parent 11db6feb45
commit 1124a10f97

View 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;
}