#ifndef HAVE_LMDB
FILE *fp = NULL;
bool cleanup_config = false;
-#else /* HAVE_LMDB */
+#else /* HAVE_LMDB */
MDB_txn *txn = NULL;
MDB_dbi dbi;
+ bool locked = false;
UNUSED(zoneconf);
- LOCK(&view->new_zone_lock);
-#endif /* HAVE_LMDB */
+#endif
/* Zone shouldn't already exist */
if (redirect) {
goto cleanup;
}
+ result = isc_task_beginexclusive(server->task);
+ RUNTIME_CHECK(result == ISC_R_SUCCESS);
+
#ifndef HAVE_LMDB
/*
* Make sure we can open the configuration save file
*/
result = isc_stdio_open(view->new_zone_file, "a", &fp);
if (result != ISC_R_SUCCESS) {
+ isc_task_endexclusive(server->task);
TCHECK(putstr(text, "unable to create '"));
TCHECK(putstr(text, view->new_zone_file));
TCHECK(putstr(text, "': "));
(void)isc_stdio_close(fp);
fp = NULL;
#else /* HAVE_LMDB */
+ LOCK(&view->new_zone_lock);
+ locked = true;
/* Make sure we can open the NZD database */
result = nzd_writable(view);
if (result != ISC_R_SUCCESS) {
+ isc_task_endexclusive(server->task);
TCHECK(putstr(text, "unable to open NZD database for '"));
TCHECK(putstr(text, view->new_zone_db));
TCHECK(putstr(text, "'"));
}
#endif /* HAVE_LMDB */
- result = isc_task_beginexclusive(server->task);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
-
/* Mark view unfrozen and configure zone */
dns_view_thaw(view);
result = configure_zone(cfg->config, zoneobj, cfg->vconfig,
if (txn != NULL) {
(void)nzd_close(&txn, false);
}
- UNLOCK(&view->new_zone_lock);
+ if (locked) {
+ UNLOCK(&view->new_zone_lock);
+ }
#endif /* HAVE_LMDB */
if (zone != NULL) {
#else /* HAVE_LMDB */
MDB_txn *txn = NULL;
MDB_dbi dbi;
- LOCK(&view->new_zone_lock);
+ bool locked = false;
#endif /* HAVE_LMDB */
/* Zone must already exist */
(void)isc_stdio_close(fp);
fp = NULL;
#else /* HAVE_LMDB */
+ LOCK(&view->new_zone_lock);
+ locked = true;
/* Make sure we can open the NZD database */
result = nzd_writable(view);
if (result != ISC_R_SUCCESS) {
if (txn != NULL) {
(void)nzd_close(&txn, false);
}
- UNLOCK(&view->new_zone_lock);
+ if (locked) {
+ UNLOCK(&view->new_zone_lock);
+ }
#endif /* HAVE_LMDB */
if (zone != NULL) {