Refactor *_destroy and *_detach functions to unified order of actions.

This properly orders clearing the freed pointer and calling isc_refcount_destroy
as early as possible to have ability to put proper memory barrier when cleaning
up reference counting.
This commit is contained in:
Ondřej Surý
2018-08-28 10:18:59 +02:00
parent 9d5df99a9d
commit 0f24c55d38
20 changed files with 156 additions and 221 deletions

View File

@@ -127,9 +127,9 @@ void
ns_server_detach(ns_server_t **sctxp) {
ns_server_t *sctx;
REQUIRE(sctxp != NULL);
REQUIRE(sctxp != NULL && SCTX_VALID(*sctxp));
sctx = *sctxp;
REQUIRE(SCTX_VALID(sctx));
*sctxp = NULL;
if (isc_refcount_decrement(&sctx->references) == 1) {
ns_altsecret_t *altsecret;
@@ -185,8 +185,6 @@ ns_server_detach(ns_server_t **sctxp) {
isc_mem_putanddetach(&sctx->mctx, sctx, sizeof(*sctx));
}
*sctxp = NULL;
}
isc_result_t