REQUIRE(VALID_SAMPLEDB(sampledb));
isc_refcount_decrement(&sampledb->refs, &refs);
- if (refs == 0)
+ if (refs == 0) {
+ isc_refcount_destroy(&sampledb->refs);
free_sampledb(sampledb);
+ }
*dbp = NULL;
}
isc_mem_free(dacl->mctx, dacl->name);
if (dacl->iptable != NULL)
dns_iptable_detach(&dacl->iptable);
- isc_refcount_destroy(&dacl->refcount);
dacl->magic = 0;
isc_mem_putanddetach(&dacl->mctx, dacl, sizeof(*dacl));
}
REQUIRE(DNS_ACL_VALID(acl));
isc_refcount_decrement(&acl->refcount, &refs);
- if (refs == 0)
+ if (refs == 0) {
+ isc_refcount_destroy(&acl->refcount);
destroy(acl);
+ }
*aclp = NULL;
}
isc_refcount_decrement(&entry->refs, &refs);
if (refs == 0) {
+ isc_refcount_destroy(&entry->refs);
dns_catz_options_free(&entry->opts, mctx);
if (dns_name_dynamic(&entry->name))
dns_name_free(&entry->name, mctx);
- isc_refcount_destroy(&entry->refs);
isc_mem_put(mctx, entry, sizeof(dns_catz_entry_t));
}
}
*zonep = NULL;
isc_refcount_decrement(&zone->refs, &refs);
if (refs == 0) {
+ isc_refcount_destroy(&zone->refs);
if (zone->entries != NULL) {
result = isc_ht_iter_create(zone->entries, &iter);
INSIST(result == ISC_R_SUCCESS);
}
mctx = zone->catzs->mctx;
isc_timer_detach(&zone->updatetimer);
- isc_refcount_destroy(&zone->refs);
if (zone->db_registered == ISC_TRUE) {
result = dns_db_updatenotify_unregister(zone->db,
dns_catz_dbupdate_callback,
isc_refcount_decrement(&catzs->refs, &refs);
if (refs == 0) {
+ isc_refcount_destroy(&catzs->refs);
DESTROYLOCK(&catzs->lock);
if (catzs->zones != NULL) {
result = isc_ht_iter_create(catzs->zones, &iter);
INSIST(isc_ht_count(catzs->zones) == 0);
isc_ht_destroy(&catzs->zones);
}
- isc_refcount_destroy(&catzs->refs);
isc_task_destroy(&catzs->updater);
isc_mem_putanddetach(&catzs->mctx, catzs, sizeof(*catzs));
}
*envp = NULL;
isc_refcount_decrement(&env->refcount, &refs);
- if (refs == 0)
+ if (refs == 0) {
+ isc_refcount_destroy(&env->refcount);
destroy(env);
+ }
}
static isc_result_t
unsigned int refs;
REQUIRE(DNS_IPTABLE_VALID(tab));
isc_refcount_decrement(&tab->refcount, &refs);
- if (refs == 0)
+ if (refs == 0) {
+ isc_refcount_destroy(&tab->refcount);
destroy_iptable(tab);
+ }
*tabp = NULL;
}
dtab->radix = NULL;
}
- isc_refcount_destroy(&dtab->refcount);
dtab->magic = 0;
isc_mem_putanddetach(&dtab->mctx, dtab, sizeof(*dtab));
}
isc_refcount_decrement(&keytable->references, &refs);
if (refs == 0) {
- INSIST(isc_refcount_current(&keytable->active_nodes) == 0);
- isc_refcount_destroy(&keytable->active_nodes);
isc_refcount_destroy(&keytable->references);
+ isc_refcount_destroy(&keytable->active_nodes);
dns_rbt_destroy(&keytable->table);
isc_rwlock_destroy(&keytable->rwlock);
keytable->magic = 0;
REQUIRE(VALID_KEYNODE(node));
isc_refcount_decrement(&node->refcount, &refs);
if (refs == 0) {
- if (node->key != NULL)
- dst_key_free(&node->key);
isc_refcount_destroy(&node->refcount);
+ if (node->key != NULL) {
+ dst_key_free(&node->key);
+ }
isc_mem_put(mctx, node, sizeof(dns_keynode_t));
}
*keynode = NULL;
*ntap = NULL;
isc_refcount_decrement(&nta->refcount, &refs);
if (refs == 0) {
+ isc_refcount_destroy(&nta->refcount);
nta->magic = 0;
if (nta->timer != NULL) {
(void) isc_timer_reset(nta->timer,
NULL, NULL, ISC_TRUE);
isc_timer_detach(&nta->timer);
}
- isc_refcount_destroy(&nta->refcount);
if (dns_rdataset_isassociated(&nta->rdataset))
dns_rdataset_disassociate(&nta->rdataset);
if (dns_rdataset_isassociated(&nta->sigrdataset))
order = *orderp;
REQUIRE(DNS_ORDER_VALID(order));
isc_refcount_decrement(&order->references, &references);
- *orderp = NULL;
- if (references != 0)
- return;
-
- order->magic = 0;
- while ((ent = ISC_LIST_HEAD(order->ents)) != NULL) {
- ISC_LIST_UNLINK(order->ents, ent, link);
- isc_mem_put(order->mctx, ent, sizeof(*ent));
+ if (references == 0) {
+ isc_refcount_destroy(&order->references);
+ order->magic = 0;
+ while ((ent = ISC_LIST_HEAD(order->ents)) != NULL) {
+ ISC_LIST_UNLINK(order->ents, ent, link);
+ isc_mem_put(order->mctx, ent, sizeof(*ent));
+ }
+ isc_mem_putanddetach(&order->mctx, order, sizeof(*order));
}
- isc_refcount_destroy(&order->references);
- isc_mem_putanddetach(&order->mctx, order, sizeof(*order));
+ *orderp = NULL;
}
*portlistp = NULL;
isc_refcount_decrement(&portlist->refcount, &count);
if (count == 0) {
- portlist->magic = 0;
isc_refcount_destroy(&portlist->refcount);
+ portlist->magic = 0;
if (portlist->list != NULL)
isc_mem_put(portlist->mctx, portlist->list,
portlist->allocated *
isc_refcount_decrement(&rbtdb->current_version->references,
&refs);
- INSIST(refs == 0);
+ isc_refcount_destroy(&rbtdb->current_version->references);
UNLINK(rbtdb->open_versions, rbtdb->current_version, link);
isc_rwlock_destroy(&rbtdb->current_version->glue_rwlock);
- isc_refcount_destroy(&rbtdb->current_version->references);
isc_rwlock_destroy(&rbtdb->current_version->rwlock);
isc_mem_put(rbtdb->common.mctx, rbtdb->current_version,
sizeof(rbtdb_version_t));
isc_refcount_decrement(&rbtdb->references, &refs);
- if (refs == 0)
+ if (refs == 0) {
maybe_free_rbtdb(rbtdb);
+ }
*dbp = NULL;
}
if (refs != 0) {
return;
}
+ isc_refcount_destroy(&rpzs->refs);
/*
* Forget the last of view's rpz machinery after the last reference.
}
DESTROYLOCK(&rpzs->maint_lock);
isc_rwlock_destroy(&rpzs->search_lock);
- isc_refcount_destroy(&rpzs->refs);
isc_task_destroy(&rpzs->updater);
isc_mem_putanddetach(&rpzs->mctx, rpzs, sizeof(*rpzs));
}
dns_name_free(key->creator, key->mctx);
isc_mem_put(key->mctx, key->creator, sizeof(dns_name_t));
}
- isc_refcount_destroy(&key->refs);
isc_mem_putanddetach(&key->mctx, key, sizeof(dns_tsigkey_t));
}
key = *keyp;
isc_refcount_decrement(&key->refs, &refs);
- if (refs == 0)
+ if (refs == 0) {
+ isc_refcount_destroy(&key->refs);
tsigkey_free(key);
+ }
*keyp = NULL;
}
dns_badcache_destroy(&view->failcache);
DESTROYLOCK(&view->new_zone_lock);
DESTROYLOCK(&view->lock);
- isc_refcount_destroy(&view->references);
isc_mem_free(view->mctx, view->nta_file);
isc_mem_free(view->mctx, view->name);
isc_mem_putanddetach(&view->mctx, view, sizeof(*view));
if (refs == 0) {
dns_zone_t *mkzone = NULL, *rdzone = NULL;
+ isc_refcount_destroy(&view->references);
+
LOCK(&view->lock);
if (!RESSHUTDOWN(view))
dns_resolver_shutdown(view->resolver);
/* last stuff */
ZONEDB_DESTROYLOCK(&zone->dblock);
DESTROYLOCK(&zone->lock);
- isc_refcount_destroy(&zone->erefs);
zone->magic = 0;
mctx = zone->mctx;
isc_mem_put(mctx, zone, sizeof(*zone));
isc_refcount_decrement(&zone->erefs, &refs);
if (refs == 0) {
+ isc_refcount_destroy(&zone->erefs);
+
LOCK_ZONE(zone);
INSIST(zone != zone->raw);
/*
isc_refcount_decrement(&actx->references, &refs);
if (refs == 0) {
+ isc_refcount_destroy(&actx->references);
for (dacl = ISC_LIST_HEAD(actx->named_acl_cache);
dacl != NULL;
dacl = next)
isc_refcount_decrement(&pctx->references, &refs);
if (refs == 0) {
+ isc_refcount_destroy(&pctx->references);
isc_lex_destroy(&pctx->lexer);
/*
* Cleaning up open_files does not
isc_refcount_decrement(&obj->references, &refs);
if (refs == 0) {
- obj->type->rep->free(pctx, obj);
isc_refcount_destroy(&obj->references);
+ obj->type->rep->free(pctx, obj);
isc_mem_put(pctx->mctx, obj, sizeof(cfg_obj_t));
}
*objp = NULL;
if (refs == 0) {
ns_altsecret_t *altsecret;
+ isc_refcount_destroy(&sctx->references);
+
sctx->magic = 0;
while ((altsecret = ISC_LIST_HEAD(sctx->altsecrets)) != NULL) {