isc_mutex_init(&view->lock);
- isc_rwlock_init(&view->sfd_lock);
-
dns_zt_create(mctx, view, &view->zonetable);
dns_fwdtable_create(mctx, view, &view->fwdtable);
dns_fwdtable_destroy(&view->fwdtable);
dns_zt_detach(&view->zonetable);
- isc_rwlock_destroy(&view->sfd_lock);
isc_mutex_destroy(&view->lock);
if (view->nta_file != NULL) {
dns_nametree_detach(&view->answernames_exclude);
}
if (view->sfd != NULL) {
- dns_rbt_destroy(&view->sfd);
+ dns_nametree_detach(&view->sfd);
}
if (view->secroots_priv != NULL) {
dns_keytable_detach(&view->secroots_priv);
dns_badcache_destroy(&view->failcache);
}
isc_mutex_destroy(&view->new_zone_lock);
- isc_rwlock_destroy(&view->sfd_lock);
isc_mutex_destroy(&view->lock);
isc_refcount_destroy(&view->references);
isc_refcount_destroy(&view->weakrefs);
view->flush = flush;
}
-static void
-free_sfd(void *data, void *arg) {
- isc_mem_put(arg, data, sizeof(unsigned int));
-}
-
void
dns_view_sfd_add(dns_view_t *view, const dns_name_t *name) {
isc_result_t result;
- dns_rbtnode_t *node = NULL;
REQUIRE(DNS_VIEW_VALID(view));
- RWLOCK(&view->sfd_lock, isc_rwlocktype_write);
if (view->sfd == NULL) {
- result = dns_rbt_create(view->mctx, free_sfd, view->mctx,
- &view->sfd);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
+ dns_nametree_create(view->mctx, DNS_NAMETREE_COUNT, "sfd",
+ &view->sfd);
}
- result = dns_rbt_addnode(view->sfd, name, &node);
- RUNTIME_CHECK(result == ISC_R_SUCCESS || result == ISC_R_EXISTS);
- if (node->data != NULL) {
- unsigned int *count = node->data;
- (*count)++;
- } else {
- unsigned int *count = isc_mem_get(view->mctx,
- sizeof(unsigned int));
- *count = 1;
- node->data = count;
- }
- RWUNLOCK(&view->sfd_lock, isc_rwlocktype_write);
+ result = dns_nametree_add(view->sfd, name, 0);
+ RUNTIME_CHECK(result == ISC_R_SUCCESS);
}
void
dns_view_sfd_del(dns_view_t *view, const dns_name_t *name) {
- isc_result_t result;
- void *data = NULL;
-
REQUIRE(DNS_VIEW_VALID(view));
- RWLOCK(&view->sfd_lock, isc_rwlocktype_write);
- INSIST(view->sfd != NULL);
- result = dns_rbt_findname(view->sfd, name, 0, NULL, &data);
- if (result == ISC_R_SUCCESS) {
- unsigned int *count = data;
- INSIST(count != NULL);
- if (--(*count) == 0U) {
- result = dns_rbt_deletename(view->sfd, name, false);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
- }
- }
- RWUNLOCK(&view->sfd_lock, isc_rwlocktype_write);
+ dns_nametree_delete(view->sfd, name);
}
void
REQUIRE(DNS_VIEW_VALID(view));
if (view->sfd != NULL) {
- isc_result_t result;
- void *data = NULL;
-
- RWLOCK(&view->sfd_lock, isc_rwlocktype_read);
- result = dns_rbt_findname(view->sfd, name, 0, foundname, &data);
- RWUNLOCK(&view->sfd_lock, isc_rwlocktype_read);
- if (result != ISC_R_SUCCESS && result != DNS_R_PARTIALMATCH) {
+ if (!dns_nametree_covered(view->sfd, name, foundname, 0)) {
dns_name_copy(dns_rootname, foundname);
}
- } else {
- dns_name_copy(dns_rootname, foundname);
}
}