mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
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.
This commit is contained in:
parent
674195e83e
commit
399f0c191a
1 changed files with 14 additions and 12 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue