]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Exclude the ADB hashmaps from ADB overmem accounting
authorOndřej Surý <ondrej@isc.org>
Tue, 13 Dec 2022 13:14:21 +0000 (14:14 +0100)
committerOndřej Surý <ondrej@isc.org>
Thu, 15 Dec 2022 15:14:16 +0000 (16:14 +0100)
The ADB overmem accounting would include the memory used by hashtables
thus vastly reducing the space that can be used for ADB names and
entries when the hashtables would grow.  Create own memory context for
the ADB names and entries hash tables.

lib/dns/adb.c

index 8dc341cc50580bdf62c30aac200838273e945dbb..9032d346025ad675cf9c6395f9b4d1d61a53bb9b 100644 (file)
@@ -104,6 +104,7 @@ struct dns_adb {
 
        isc_mutex_t lock;
        isc_mem_t *mctx;
+       isc_mem_t *hmctx;
        dns_view_t *view;
        dns_resolver_t *res;
        size_t nloops;
@@ -1863,6 +1864,8 @@ destroy(dns_adb_t *adb) {
        UNLOCK(&adb->entries_lock);
        isc_mutex_destroy(&adb->entries_lock);
 
+       isc_mem_destroy(&adb->hmctx);
+
        isc_mutex_destroy(&adb->lock);
        isc_refcount_destroy(&adb->references);
 
@@ -1919,12 +1922,14 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_loopmgr_t *loopmgr,
        dns_resolver_attach(view->resolver, &adb->res);
        isc_mem_attach(mem, &adb->mctx);
 
-       isc_hashmap_create(adb->mctx, ADB_HASH_BITS,
+       isc_mem_create(&adb->hmctx);
+
+       isc_hashmap_create(adb->hmctx, ADB_HASH_BITS,
                           ISC_HASHMAP_CASE_INSENSITIVE, &adb->names);
        isc_mutex_init(&adb->names_lock);
 
-       isc_hashmap_create(adb->mctx, ADB_HASH_BITS, ISC_HASHMAP_CASE_SENSITIVE,
-                          &adb->entries);
+       isc_hashmap_create(adb->hmctx, ADB_HASH_BITS,
+                          ISC_HASHMAP_CASE_SENSITIVE, &adb->entries);
        isc_mutex_init(&adb->entries_lock);
 
        isc_mutex_init(&adb->lock);
@@ -1975,6 +1980,8 @@ free_tasks:
        isc_hashmap_destroy(&adb->names);
        INSIST(ISC_LIST_EMPTY(adb->names_lru));
 
+       isc_mem_destroy(&adb->hmctx);
+
        dns_resolver_detach(&adb->res);
        dns_view_weakdetach(&adb->view);
        isc_mem_putanddetach(&adb->mctx, adb, sizeof(dns_adb_t));