isc_refcount_increment(&zl->refs);
result = dns_view_asyncload(view, reconfig, view_loaded, zl);
if (result != ISC_R_SUCCESS) {
- (void)isc_refcount_decrement(&zl->refs);
+ isc_refcount_decrement1(&zl->refs);
goto cleanup;
}
}
result = isc_task_onshutdown(cleaner->task,
cleaner_shutdown_action, cache);
if (result != ISC_R_SUCCESS) {
- isc_refcount_decrement(&cleaner->cache->live_tasks);
+ isc_refcount_decrement0(&cleaner->cache->live_tasks);
UNEXPECTED_ERROR(__FILE__, __LINE__,
"cache cleaner: "
"isc_task_onshutdown() failed: %s",
/* Make sure we don't reschedule anymore. */
(void)isc_task_purge(task, NULL, DNS_EVENT_CACHECLEAN, NULL);
- INSIST(isc_refcount_decrement(&cache->live_tasks) == 1);
+ isc_refcount_decrementz(&cache->live_tasks);
cache_free(cache);
}
return (ISC_R_SUCCESS);
cleanup_references:
- isc_refcount_decrement(&client->references);
+ isc_refcount_decrementz(&client->references);
isc_refcount_destroy(&client->references);
cleanup_dispatchmgr:
if (dispatchv4 != NULL) {
return (ISC_R_SUCCESS);
}
- isc_refcount_decrement(&client->references);
+ isc_refcount_decrement1(&client->references);
LOCK(&client->lock);
ISC_LIST_UNLINK(client->reqctxs, ctx, link);
return (result);
}
- isc_refcount_decrement(&client->references);
+ isc_refcount_decrement1(&client->references);
*transp = NULL;
fail:
REQUIRE(rbtdb->future_version == NULL);
if (rbtdb->current_version != NULL) {
- INSIST(isc_refcount_decrement(
- &rbtdb->current_version->references) == 1);
-
+ isc_refcount_decrementz(&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);
rbtdb->next_serial = 2;
rbtdb->current_version = allocate_version(mctx, 1, 1, false);
if (rbtdb->current_version == NULL) {
- isc_refcount_decrement(&rbtdb->references);
+ isc_refcount_decrementz(&rbtdb->references);
free_rbtdb(rbtdb, false, NULL);
return (ISC_R_NOMEMORY);
}
isc_mem_put(mctx, rbtdb->current_version,
sizeof(*rbtdb->current_version));
rbtdb->current_version = NULL;
- isc_refcount_decrement(&rbtdb->references);
+ isc_refcount_decrementz(&rbtdb->references);
free_rbtdb(rbtdb, false, NULL);
return (result);
}
ISC_LIST_UNLINK(res->buckets[bucketnum].fctxs, fctx, link);
- REQUIRE(atomic_fetch_sub_release(&res->nfctx, 1) > 0);
+ INSIST(atomic_fetch_sub_release(&res->nfctx, 1) > 0);
dec_stats(res, dns_resstatscounter_nfetch);
ISC_LIST_APPEND(res->buckets[bucketnum].fctxs, fctx, link);
- REQUIRE(atomic_fetch_add_relaxed(&res->nfctx, 1) < UINT32_MAX);
+ INSIST(atomic_fetch_add_relaxed(&res->nfctx, 1) < UINT32_MAX);
inc_stats(res, dns_resstatscounter_nfetch);
dns_rbt_destroy(&zones->rbt);
cleanup_rbt:
- isc_refcount_decrement(&zones->irefs);
+ isc_refcount_decrementz(&zones->irefs);
isc_refcount_destroy(&zones->irefs);
- isc_refcount_decrement(&zones->refs);
+ isc_refcount_decrementz(&zones->refs);
isc_refcount_destroy(&zones->refs);
isc_mutex_destroy(&zones->maint_lock);
isc_timer_detach(&zone->updatetimer);
cleanup_timer:
- isc_refcount_decrement(&zone->refs);
+ isc_refcount_decrementz(&zone->refs);
isc_refcount_destroy(&zone->refs);
isc_mem_put(rpzs->mctx, zone, sizeof(*zone));
}
if (result != ISC_R_SUCCESS) {
- isc_refcount_decrement(&node->references);
+ isc_refcount_decrementz(&node->references);
destroynode(node);
return (result);
}
sdlz->dbdata, node);
MAYBE_UNLOCK(sdlz->dlzimp);
if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
- isc_refcount_decrement(&node->references);
+ isc_refcount_decrementz(&node->references);
destroynode(node);
return (result);
}
dns_sdlznode_t *node;
node = ISC_LIST_HEAD(sdlziter->nodelist);
ISC_LIST_UNLINK(sdlziter->nodelist, node, link);
- isc_refcount_decrement(&node->references);
+ isc_refcount_decrementz(&node->references);
destroynode(node);
}
cleanup_refs:
tkey->magic = 0;
while (refs-- > 0) {
- isc_refcount_decrement(&tkey->refs);
+ isc_refcount_decrement0(&tkey->refs);
}
isc_refcount_destroy(&tkey->refs);
}
cleanup_weakrefs:
- isc_refcount_decrement(&view->weakrefs);
+ isc_refcount_decrementz(&view->weakrefs);
isc_refcount_destroy(&view->weakrefs);
- isc_refcount_decrement(&view->references);
+ isc_refcount_decrementz(&view->references);
isc_refcount_destroy(&view->references);
if (view->fwdtable != NULL) {
return (ISC_R_SUCCESS);
free_refs:
- isc_refcount_decrement(&zone->erefs);
+ isc_refcount_decrement0(&zone->erefs);
isc_refcount_destroy(&zone->erefs);
isc_refcount_destroy(&zone->irefs);
* Caller is holding a reference to zt->loads_pending
* and zt->references so these can't decrement to zero.
*/
- INSIST(isc_refcount_decrement(&zt->loads_pending) > 1);
- INSIST(isc_refcount_decrement(&zt->references) > 1);
+ isc_refcount_decrement1(&zt->references);
+ isc_refcount_decrement1(&zt->loads_pending);
}
return (ISC_R_SUCCESS);
}
cleanup:
httpdmgr->magic = 0;
- isc_refcount_decrement(&httpdmgr->references);
+ isc_refcount_decrementz(&httpdmgr->references);
isc_refcount_destroy(&httpdmgr->references);
isc_mem_detach(&httpdmgr->mctx);
isc_mutex_destroy(&httpdmgr->lock);
})
#endif /* _MSC_VER */
+#define isc_refcount_decrementz(target) \
+ do { \
+ uint_fast32_t _refs = isc_refcount_decrement(target); \
+ ISC_INSIST(_refs == 1); \
+ } while (0)
+
+#define isc_refcount_decrement1(target) \
+ do { \
+ uint_fast32_t _refs = isc_refcount_decrement(target); \
+ ISC_INSIST(_refs > 1); \
+ } while (0)
+
+#define isc_refcount_decrement0(target) \
+ do { \
+ uint_fast32_t _refs = isc_refcount_decrement(target); \
+ ISC_INSIST(_refs > 0); \
+ } while (0)
+
ISC_LANG_ENDDECLS
print_active(ctx, stderr);
}
#else /* if ISC_MEM_TRACKLINES */
- isc_refcount_decrement(&ctx->references);
+ isc_refcount_decrementz(&ctx->references);
#endif /* if ISC_MEM_TRACKLINES */
isc_refcount_destroy(&ctx->references);
destroy(ctx);
inc_stats(manager->stats, sock->statsindex[STATID_ACCEPT]);
} else {
inc_stats(manager->stats, sock->statsindex[STATID_ACCEPTFAIL]);
- (void)isc_refcount_decrement(&NEWCONNSOCK(dev)->references);
+ isc_refcount_decrementz(&NEWCONNSOCK(dev)->references);
free_socket((isc__socket_t **)&dev->newsocket);
}
ISC_LIST_UNLINK(sock->accept_list, dev,
ev_link);
- (void)isc_refcount_decrement(
+ isc_refcount_decrementz(
&NEWCONNSOCK(dev)->references);
free_socket((isc__socket_t **)&dev->newsocket);
closesocket(lpo->adev->newsocket->fd);
lpo->adev->newsocket->fd =
INVALID_SOCKET;
- isc_refcount_decrement(
+ isc_refcount_decrementz(
&lpo->adev->newsocket
->references);
free_socket(&lpo->adev->newsocket,
next = ISC_LIST_NEXT(dev, ev_link);
if ((task == NULL) || (task == current_task)) {
- isc_refcount_decrement(
+ isc_refcount_decrementz(
&dev->newsocket->references);
closesocket(dev->newsocket->fd);
dev->newsocket->fd = INVALID_SOCKET;