]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Also cleanup the space for the rbt nodes
authorMark Andrews <marka@isc.org>
Tue, 5 Dec 2023 02:15:03 +0000 (13:15 +1100)
committerMark Andrews <marka@isc.org>
Thu, 7 Dec 2023 02:59:04 +0000 (02:59 +0000)
As we are in overmem state we want to free more memory than we are
adding so we need to add in an allowance for the rbtnodes that may
have been added and the names stored with them.  There is the node
for the owner name and a possible ENT node if there was a node split.

lib/dns/include/dns/rbt.h
lib/dns/rbt-cachedb.c
lib/dns/rbt.c

index 08b4803ab99aaef7a3adeca2d30e7f5d241c66ae..93e429069bbed92075fbfc7f75df7d6a718466ad 100644 (file)
@@ -991,4 +991,11 @@ dns__rbtnode_namelen(dns_rbtnode_t *node);
  * Returns the length of the full name of the node. Used only internally
  * and in unit tests.
  */
+
+unsigned int
+dns__rbtnode_getsize(dns_rbtnode_t *node);
+/*
+ * Return allocated size for a node.
+ */
+
 ISC_LANG_ENDDECLS
index 51d56c4ede742cb39760db2c919a10103bc5dca9..ea2ff089969ce35e8cd07a073ca363c4f5cf5300 100644 (file)
@@ -1673,7 +1673,9 @@ dns__cachedb_overmem(dns_rbtdb_t *rbtdb, dns_slabheader_t *newheader,
                     isc_rwlocktype_t *tlocktypep DNS__DB_FLARG) {
        uint32_t locknum_start = rbtdb->lru_sweep++ % rbtdb->node_lock_count;
        uint32_t locknum = locknum_start;
-       size_t purgesize = rdataset_size(newheader);
+       /* Size of added data, possible node and possible ENT node. */
+       size_t purgesize = rdataset_size(newheader) +
+                          2 * dns__rbtnode_getsize(HEADER_NODE(newheader));
        size_t purged = 0;
        isc_stdtime_t min_last_used = 0;
        size_t max_passes = 8;
index f4115d1070eba08227583037eb78cb2e1301489b..07028f6b1336dc0620910b17ec166f95ca9d0849 100644 (file)
@@ -251,6 +251,13 @@ dns__rbtnode_namelen(dns_rbtnode_t *node) {
        return (len);
 }
 
+unsigned int
+dns__rbtnode_getsize(dns_rbtnode_t *node) {
+       REQUIRE(DNS_RBTNODE_VALID(node));
+
+       return (NODE_SIZE(node));
+}
+
 /*
  * Initialize a red/black tree of trees.
  */