]> 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 10:50:02 +0000 (21:50 +1100)
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.

(cherry picked from commit 7e462c2b26299f77944fb225923b7b01e0017856)

lib/dns/include/dns/rbt.h
lib/dns/rbt.c
lib/dns/rbtdb.c

index 3b62e121149e407ba7b8e8121d22f5f1258e6da5..c144f83b49d136bfc7f1eb156bab59b56faec726 100644 (file)
@@ -992,4 +992,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 57dcd54542feb75ac9f3a7b1089dd6f689460627..4d8c142fc2798226698f69e1441a0c46e0537b13 100644 (file)
@@ -302,6 +302,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.
  */
index 55776d5a74a2cc0fda88793b0d33682ba8c76b86..864a159097aa675002bf6b203794575fe1dd1e94 100644 (file)
@@ -10201,7 +10201,9 @@ overmem_purge(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader,
              bool tree_locked) {
        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(newheader->node);
        size_t purged = 0;
        isc_stdtime_t min_last_used = 0;
        size_t max_passes = 8;