"for view '%s'",
view->new_zone_db, view->name);
+ LOCK(&view->new_zone_lock);
+
CHECK(nzd_count(view, &n));
*num_zonesp = n;
if (result != ISC_R_SUCCESS)
*num_zonesp = 0;
+ UNLOCK(&view->new_zone_lock);
+
return (ISC_R_SUCCESS);
}
* Immediately interrupt processing if an error is encountered while
* transforming NZD data into a zone configuration object or if "callback"
* returns an error.
+ *
+ * Caller must hold 'view->new_zone_lock'.
*/
static isc_result_t
for_all_newzone_cfgs(newzone_cfg_cb_t callback, cfg_obj_t *config,
return (ISC_R_SUCCESS);
}
+ LOCK(&view->new_zone_lock);
+
result = nzd_open(view, MDB_RDONLY, &txn, &dbi);
if (result != ISC_R_SUCCESS) {
+ UNLOCK(&view->new_zone_lock);
return (ISC_R_SUCCESS);
}
}
(void) nzd_close(&txn, false);
+
+ UNLOCK(&view->new_zone_lock);
+
return (result);
}
INSIST(zoneconfig != NULL && *zoneconfig == NULL);
+ LOCK(&view->new_zone_lock);
+
CHECK(nzd_open(view, MDB_RDONLY, &txn, &dbi));
isc_log_write(ns_g_lctx,
cleanup:
(void) nzd_close(&txn, false);
+ UNLOCK(&view->new_zone_lock);
+
if (zoneconf != NULL) {
cfg_obj_destroy(ns_g_addparser, &zoneconf);
}
nzd_setkey(&key, dns_zone_getorigin(zone), namebuf, sizeof(namebuf));
- LOCK(&view->new_zone_lock);
-
if (zconfig == NULL) {
/* We're deleting the zone from the database */
status = mdb_del(*txnp, dbi, &key, NULL);
}
*txnp = NULL;
- UNLOCK(&view->new_zone_lock);
-
if (text != NULL) {
isc_buffer_free(&text);
}
return (result);
}
+/*
+ * Check whether the new zone database for 'view' can be opened for writing.
+ *
+ * Caller must hold 'view->new_zone_lock'.
+ */
static isc_result_t
nzd_writable(dns_view_t *view) {
isc_result_t result = ISC_R_SUCCESS;
return (result);
}
+/*
+ * Open the new zone database for 'view' and start a transaction for it.
+ *
+ * Caller must hold 'view->new_zone_lock'.
+ */
static isc_result_t
nzd_open(dns_view_t *view, unsigned int flags, MDB_txn **txnp, MDB_dbi *dbi) {
int status;
return (result);
}
+/*
+ * If 'commit' is true, commit the new zone database transaction pointed to by
+ * 'txnp'; otherwise, abort that transaction.
+ *
+ * Caller must hold 'view->new_zone_lock' for the view that the transaction
+ * pointed to by 'txnp' was started for.
+ */
static isc_result_t
nzd_close(MDB_txn **txnp, bool commit) {
isc_result_t result = ISC_R_SUCCESS;
return (result);
}
+/*
+ * Count the zones configured in the new zone database for 'view' and store the
+ * result in 'countp'.
+ *
+ * Caller must hold 'view->new_zone_lock'.
+ */
static isc_result_t
nzd_count(dns_view_t *view, int *countp) {
isc_result_t result;
MDB_val key, data;
ns_dzarg_t dzarg;
+ LOCK(&view->new_zone_lock);
+
/*
* If NZF file doesn't exist, or NZD DB exists and already
* has data, return without attempting migration.
result = nzd_close(&txn, commit);
}
+ UNLOCK(&view->new_zone_lock);
+
if (text != NULL) {
isc_buffer_free(&text);
}
MDB_dbi dbi;
UNUSED(zoneconf);
+ LOCK(&view->new_zone_lock);
#endif /* HAVE_LMDB */
/* Zone shouldn't already exist */
#else /* HAVE_LMDB */
if (txn != NULL)
(void) nzd_close(&txn, false);
+ 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);
#endif /* HAVE_LMDB */
/* Zone must already exist */
#else /* HAVE_LMDB */
if (txn != NULL)
(void) nzd_close(&txn, false);
+ UNLOCK(&view->new_zone_lock);
#endif /* HAVE_LMDB */
if (zone != NULL)
if (added && cfg != NULL) {
#ifdef HAVE_LMDB
/* Make sure we can open the NZD database */
+ LOCK(&view->new_zone_lock);
result = nzd_open(view, 0, &txn, &dbi);
if (result != ISC_R_SUCCESS) {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
"delete zone configuration: %s",
isc_result_totext(result));
}
+
+ if (txn != NULL) {
+ (void)nzd_close(&txn, false);
+ }
+ UNLOCK(&view->new_zone_lock);
#else
result = delete_zoneconf(view, cfg->add_parser,
cfg->nzf_config,
}
}
-#ifdef HAVE_LMDB
- if (txn != NULL)
- (void) nzd_close(&txn, false);
-#endif
if (raw != NULL)
dns_zone_detach(&raw);
dns_zone_detach(&zone);