From a9383e4b95256a65f9f05e64a79b086a9a1ed035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 20 Feb 2024 08:50:58 +0100 Subject: [PATCH] Remove expired rdataset headers from the heap It was discovered that an expired header could sit on top of the heap a little longer than desireable. Remove expired headers (headers with rdh_ttl set to 0) from the heap completely, so they don't block the next TTL-based cleaning. --- lib/dns/rbtdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 337ebbd876..d813bb4d89 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -337,6 +337,10 @@ dns__rbtdb_setttl(dns_slabheader_t *header, dns_ttl_t newttl) { } else { isc_heap_decreased(header->heap, header->heap_index); } + + if (newttl == 0) { + isc_heap_delete(header->heap, header->heap_index); + } } static bool @@ -4851,7 +4855,6 @@ dns__rbtdb_deletedata(dns_db_t *db ISC_ATTR_UNUSED, if (header->heap != NULL && header->heap_index != 0) { isc_heap_delete(header->heap, header->heap_index); } - header->heap_index = 0; if (IS_CACHE(rbtdb)) { update_rrsetstats(rbtdb->rrsetstats, header->type,