static isc_result_t
delete_zoneconf(dns_view_t *view, const cfg_obj_t *config,
- const dns_name_t *zname, nzfwriter_t nzfwriter) {
+ const dns_name_t *zname, nzfwriter_t nzfwriter, bool locked) {
isc_result_t result = ISC_R_NOTFOUND;
const cfg_obj_t *zl = NULL;
REQUIRE(config != NULL);
REQUIRE(zname != NULL);
- LOCK(&view->newzone.lock);
+ if (!locked) {
+ LOCK(&view->newzone.lock);
+ }
cfg_map_get(config, "zone", &zl);
}
cleanup:
- UNLOCK(&view->newzone.lock);
+ if (!locked) {
+ UNLOCK(&view->newzone.lock);
+ }
return result;
}
isc_result_t result, tresult;
dns_zone_t *zone = NULL;
const cfg_obj_t *voptions = NULL;
+ bool locked = false;
#ifndef HAVE_LMDB
FILE *fp = NULL;
bool cleanup_config = false;
#else /* HAVE_LMDB */
MDB_txn *txn = NULL;
MDB_dbi dbi;
- bool locked = false;
UNUSED(zoneconf);
#endif
}
if (result != ISC_R_SUCCESS && cleanup_config) {
tresult = delete_zoneconf(view, view->newzone.nzconfig, name,
- NULL);
+ NULL, locked);
RUNTIME_CHECK(tresult == ISC_R_SUCCESS);
}
#else /* HAVE_LMDB */
dns_zone_t *zone = NULL;
const cfg_obj_t *voptions = NULL;
bool added;
+ bool locked = false;
#ifndef HAVE_LMDB
FILE *fp = NULL;
cfg_obj_t *z;
#else /* HAVE_LMDB */
MDB_txn *txn = NULL;
MDB_dbi dbi;
- bool locked = false;
#endif /* HAVE_LMDB */
if (!view->newzone.allowed) {
if (added) {
result = delete_zoneconf(view, view->newzone.nzconfig,
dns_zone_getorigin(zone),
- nzf_writeconf);
+ nzf_writeconf, locked);
if (result != ISC_R_SUCCESS) {
TCHECK(putstr(text, "former zone configuration "
"not deleted: "));
if (!added) {
if (view->newzone.vconfig == NULL) {
result = delete_zoneconf(view, server->effectiveconfig,
- dns_zone_getorigin(zone),
- NULL);
+ dns_zone_getorigin(zone), NULL,
+ locked);
} else {
voptions = cfg_tuple_get(server->effectiveconfig,
"options");
- result = delete_zoneconf(
- view, voptions, dns_zone_getorigin(zone), NULL);
+ result = delete_zoneconf(view, voptions,
+ dns_zone_getorigin(zone), NULL,
+ locked);
}
if (result != ISC_R_SUCCESS) {
dns_view_t *view = NULL;
dns_db_t *dbp = NULL;
bool added;
+ bool locked = false;
isc_result_t result;
#ifdef HAVE_LMDB
MDB_txn *txn = NULL;
#ifdef HAVE_LMDB
/* 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,
(void)nzd_close(&txn, false);
}
UNLOCK(&view->newzone.lock);
+ locked = false;
#else /* ifdef HAVE_LMDB */
result = delete_zoneconf(view, view->newzone.nzconfig,
dns_zone_getorigin(zone),
- nzf_writeconf);
+ nzf_writeconf, locked);
if (result != ISC_R_SUCCESS) {
isc_log_write(NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
if (view->newzone.vconfig != NULL) {
const cfg_obj_t *voptions =
cfg_tuple_get(view->newzone.vconfig, "options");
- result = delete_zoneconf(
- view, voptions, dns_zone_getorigin(zone), NULL);
+ result = delete_zoneconf(view, voptions,
+ dns_zone_getorigin(zone), NULL,
+ locked);
} else {
result = delete_zoneconf(
view, dz->server->effectiveconfig,
- dns_zone_getorigin(zone), NULL);
+ dns_zone_getorigin(zone), NULL, locked);
}
if (result != ISC_R_SUCCESS) {