From: Ondřej Surý Date: Fri, 9 Jul 2021 12:35:00 +0000 (+0200) Subject: Properly disable the "water" in isc_mem X-Git-Tag: v9.17.17~40^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9c3bebc26f943566a685d343fcc32a0402c11f9a;p=thirdparty%2Fbind9.git Properly disable the "water" in isc_mem The proper way how to disable the water limit in the isc_mem context is to call: isc_mem_setwater(ctx, NULL, NULL, 0, 0); this ensures that the old water callback is called with ISC_MEM_LOWATER if the callback was called with ISC_MEM_HIWATER before. Historically, there were some places where the limits were disabled by calling: isc_mem_setwater(ctx, water, water_arg, 0, 0); which would also call the old callback, but it also causes the water_t to be allocated and extra check to be executed because water callback is not NULL. This commits unifies the calls to disable water to the preferred form. --- diff --git a/lib/dns/adb.c b/lib/dns/adb.c index defb75c44ce..6b1bddad636 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -2869,7 +2869,7 @@ dns_adb_shutdown(dns_adb_t *adb) { if (!adb->shutting_down) { adb->shutting_down = true; - isc_mem_setwater(adb->mctx, water, adb, 0, 0); + isc_mem_setwater(adb->mctx, NULL, NULL, 0, 0); /* * Isolate shutdown_names and shutdown_entries calls. */ @@ -4699,7 +4699,7 @@ dns_adb_setadbsize(dns_adb_t *adb, size_t size) { lowater = size - (size >> 2); /* Approximately 3/4ths. */ if (size == 0U || hiwater == 0U || lowater == 0U) { - isc_mem_setwater(adb->mctx, water, adb, 0, 0); + isc_mem_setwater(adb->mctx, NULL, NULL, 0, 0); } else { isc_mem_setwater(adb->mctx, water, adb, hiwater, lowater); } diff --git a/lib/dns/cache.c b/lib/dns/cache.c index 9935275d8f6..bf73300c058 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -950,7 +950,7 @@ dns_cache_setcachesize(dns_cache_t *cache, size_t size) { /* * Disable cache memory limiting. */ - isc_mem_setwater(cache->mctx, water, cache, 0, 0); + isc_mem_setwater(cache->mctx, NULL, NULL, 0, 0); } else { /* * Establish new cache memory limits (either for the first