2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Use static storage for isc_mem water_t

On the isc_mem water change the old water_t structure could be used
after free.  Instead of introducing reference counting on the hot-path
we are going to introduce additional constraints on the
isc_mem_setwater.  Once it's set for the first time, the additional
calls have to be made with the same water and water_arg arguments.
This commit is contained in:
Ondřej Surý
2021-07-22 06:14:32 +02:00
parent 240f9d2037
commit 22db2705cd
4 changed files with 83 additions and 78 deletions

View File

@@ -167,6 +167,9 @@ cleaner_shutdown_action(isc_task_t *task, isc_event_t *event);
static void
overmem_cleaning_action(isc_task_t *task, isc_event_t *event);
static void
water(void *arg, int mark);
static inline isc_result_t
cache_create_db(dns_cache_t *cache, dns_db_t **db) {
isc_result_t result;
@@ -328,7 +331,7 @@ cache_free(dns_cache_t *cache) {
isc_refcount_destroy(&cache->references);
isc_refcount_destroy(&cache->live_tasks);
isc_mem_setwater(cache->mctx, NULL, NULL, 0, 0);
isc_mem_clearwater(cache->mctx);
if (cache->cleaner.task != NULL) {
isc_task_detach(&cache->cleaner.task);
@@ -950,7 +953,7 @@ dns_cache_setcachesize(dns_cache_t *cache, size_t size) {
/*
* Disable cache memory limiting.
*/
isc_mem_setwater(cache->mctx, NULL, NULL, 0, 0);
isc_mem_clearwater(cache->mctx);
} else {
/*
* Establish new cache memory limits (either for the first