dns_view_t *view;
} matching_view_ctx_t;
-/*%
- * A function to write out added-zone configuration to the new_zone_file
- * specified in 'view'. Maybe called by delete_zoneconf().
- */
-typedef isc_result_t (*nzfwriter_t)(const cfg_obj_t *config, dns_view_t *view);
-
/*%
* Holds state information for the initial zone loading process.
* Uses the isc_refcount structure to count the number of views
static isc_result_t
delete_zoneconf(dns_view_t *view, const cfg_obj_t *config,
- const dns_name_t *zname, nzfwriter_t nzfwriter, bool locked) {
- isc_result_t result = ISC_R_NOTFOUND;
+ const dns_name_t *zname) {
const cfg_obj_t *zl = NULL;
REQUIRE(view != NULL);
REQUIRE(config != NULL);
REQUIRE(zname != NULL);
- if (!locked) {
- LOCK(&view->newzone.lock);
- }
-
cfg_map_get(config, "zone", &zl);
if (!cfg_obj_islist(zl)) {
- CLEANUP(ISC_R_FAILURE);
+ return ISC_R_FAILURE;
}
cfg_list_t *list = UNCONST(zl->value.list);
ISC_LIST_FOREACH(*list, elt, link) {
+ isc_result_t result;
dns_fixedname_t myfixed;
dns_name_t *myname = dns_fixedname_initname(&myfixed);
const cfg_obj_t *zconf = cfg_listelt_value(elt);
cfg_obj_t *zones = UNCONST(zl);
cfg_list_unlink(zones, elt);
- result = ISC_R_SUCCESS;
- break;
- }
-
- /*
- * Write config to NZF file if appropriate
- */
- if (nzfwriter != NULL && view->newzone.file != NULL) {
- result = nzfwriter(config, view);
+ return ISC_R_SUCCESS;
}
-cleanup:
- if (!locked) {
- UNLOCK(&view->newzone.lock);
- }
- return result;
+ return ISC_R_NOTFOUND;
}
static isc_result_t
dns_zone_t *zone = NULL;
const cfg_obj_t *voptions = NULL;
bool added;
- bool locked = false;
MDB_txn *txn = NULL;
MDB_dbi dbi;
isc_loopmgr_pause();
LOCK(&view->newzone.lock);
- locked = true;
/* Make sure we can open the NZD database */
result = nzd_writable(view);
if (result != ISC_R_SUCCESS) {
if (!added) {
if (view->newzone.vconfig == NULL) {
result = delete_zoneconf(view, server->effectiveconfig,
- dns_zone_getorigin(zone), NULL,
- locked);
+ dns_zone_getorigin(zone));
} else {
voptions = cfg_tuple_get(server->effectiveconfig,
"options");
result = delete_zoneconf(view, voptions,
- dns_zone_getorigin(zone), NULL,
- locked);
+ dns_zone_getorigin(zone));
}
if (result != ISC_R_SUCCESS) {
if (txn != NULL) {
(void)nzd_close(&txn, false);
}
- if (locked) {
- UNLOCK(&view->newzone.lock);
- }
+
+ UNLOCK(&view->newzone.lock);
if (zone != NULL) {
dns_zone_detach(&zone);
}
dns_view_t *view = NULL;
dns_db_t *dbp = NULL;
bool added;
- bool locked = false;
isc_result_t result;
MDB_txn *txn = NULL;
MDB_dbi dbi;
added = dns_zone_getadded(zone);
catz = dns_zone_get_parentcatz(zone);
+ LOCK(&view->newzone.lock);
+
if (added && catz == NULL) {
/* Make sure we can open the NZD database */
- LOCK(&view->newzone.lock);
- locked = true;
result = nzd_open(view, 0, &txn, &dbi);
if (result != ISC_R_SUCCESS) {
isc_log_write(NAMED_LOGCATEGORY_GENERAL,
if (txn != NULL) {
(void)nzd_close(&txn, false);
}
- UNLOCK(&view->newzone.lock);
- locked = false;
}
if (!added) {
const cfg_obj_t *voptions =
cfg_tuple_get(view->newzone.vconfig, "options");
result = delete_zoneconf(view, voptions,
- dns_zone_getorigin(zone), NULL,
- locked);
+ dns_zone_getorigin(zone));
} else {
- result = delete_zoneconf(
- view, dz->server->effectiveconfig,
- dns_zone_getorigin(zone), NULL, locked);
+ result = delete_zoneconf(view,
+ dz->server->effectiveconfig,
+ dns_zone_getorigin(zone));
}
if (result != ISC_R_SUCCESS) {
}
}
+ UNLOCK(&view->newzone.lock);
+
/* Unload zone database */
if (dns_zone_getdb(zone, &dbp) == ISC_R_SUCCESS) {
dns_db_detach(&dbp);