2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

REQUIRE should not have side effects

it's a style violation to have REQUIRE or INSIST contain code that
must run for the server to work. this was being done with some
atomic_compare_exchange calls. these have been cleaned up.  uses
of atomic_compare_exchange in assertions have been replaced with
a new macro atomic_compare_exchange_enforced, which uses RUNTIME_CHECK
to ensure that the exchange was successful.
This commit is contained in:
Evan Hunt
2021-10-21 02:28:48 -07:00
parent 7e49c5e38a
commit a499794984
12 changed files with 80 additions and 55 deletions

View File

@@ -414,12 +414,15 @@ mem_getstats(isc_mem_t *ctx, size_t size) {
static void
mem_putstats(isc_mem_t *ctx, void *ptr, size_t size) {
struct stats *stats = stats_bucket(ctx, size);
uint_fast32_t s, g;
UNUSED(ptr);
INSIST(atomic_fetch_sub_release(&ctx->inuse, size) >= size);
s = atomic_fetch_sub_release(&ctx->inuse, size);
INSIST(s >= size);
INSIST(atomic_fetch_sub_release(&stats->gets, 1) >= 1);
g = atomic_fetch_sub_release(&stats->gets, 1);
INSIST(g >= 1);
decrement_malloced(ctx, size);
}