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.
(cherry picked from commit 399f0c191a)
This commit is contained in:
parent
11db6feb45
commit
1124a10f97
1 changed files with 14 additions and 12 deletions
|
|
@ -78,6 +78,8 @@ typedef enum {
|
||||||
* Incoming zone transfer context.
|
* Incoming zone transfer context.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
typedef struct dns_ixfr dns_ixfr_t;
|
||||||
|
|
||||||
struct dns_xfrin {
|
struct dns_xfrin {
|
||||||
unsigned int magic;
|
unsigned int magic;
|
||||||
isc_mem_t *mctx;
|
isc_mem_t *mctx;
|
||||||
|
|
@ -170,7 +172,7 @@ struct dns_xfrin {
|
||||||
*/
|
*/
|
||||||
dns_rdatacallbacks_t axfr;
|
dns_rdatacallbacks_t axfr;
|
||||||
|
|
||||||
struct {
|
struct dns_ixfr {
|
||||||
uint32_t request_serial;
|
uint32_t request_serial;
|
||||||
uint32_t current_serial;
|
uint32_t current_serial;
|
||||||
dns_journal_t *journal;
|
dns_journal_t *journal;
|
||||||
|
|
@ -485,24 +487,22 @@ cleanup:
|
||||||
}
|
}
|
||||||
|
|
||||||
static isc_result_t
|
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;
|
isc_result_t result = ISC_R_SUCCESS;
|
||||||
|
|
||||||
if (xfr->ixfr.journal != NULL) {
|
if (ixfr->journal != NULL) {
|
||||||
CHECK(dns_journal_begin_transaction(xfr->ixfr.journal));
|
CHECK(dns_journal_begin_transaction(ixfr->journal));
|
||||||
}
|
}
|
||||||
cleanup:
|
cleanup:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static isc_result_t
|
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;
|
isc_result_t result = ISC_R_SUCCESS;
|
||||||
|
|
||||||
CHECK(dns_zone_verifydb(xfr->zone, xfr->db, xfr->ver));
|
|
||||||
/* XXX enter ready-to-commit state here */
|
/* XXX enter ready-to-commit state here */
|
||||||
if (xfr->ixfr.journal != NULL) {
|
if (ixfr->journal != NULL) {
|
||||||
CHECK(dns_journal_commit(xfr->ixfr.journal));
|
CHECK(dns_journal_commit(ixfr->journal));
|
||||||
}
|
}
|
||||||
cleanup:
|
cleanup:
|
||||||
return result;
|
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;
|
isc_result_t result = ISC_R_SUCCESS;
|
||||||
uint64_t records;
|
uint64_t records;
|
||||||
|
|
||||||
CHECK(ixfr_begin_transaction(xfr));
|
CHECK(ixfr_begin_transaction(&xfr->ixfr));
|
||||||
|
|
||||||
CHECK(dns_diff_apply(&data->diff, xfr->db, xfr->ver));
|
CHECK(dns_diff_apply(&data->diff, xfr->db, xfr->ver));
|
||||||
if (xfr->maxrecords != 0U) {
|
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));
|
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;
|
return result;
|
||||||
cleanup:
|
cleanup:
|
||||||
/* We need to end the transaction, but keep the previous error */
|
/* We need to end the transaction, but keep the previous error */
|
||||||
(void)ixfr_end_transaction(xfr);
|
(void)ixfr_end_transaction(&xfr->ixfr);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue