From 03ff80a1f79deedfb597a070c3bfbff6d2c67b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Sat, 14 Mar 2026 09:45:05 +0100 Subject: [PATCH] Move ADB TTL-based cleanup into dump_adb() Instead of doing a full sweep of all names and entries before dumping, expire stale entries lazily as they are encountered during the dump iteration. This aligns with the QPcache approach of avoiding separate TTL-based cleaning passes. dns_adb_flush() retains its explicit full sweep since it needs to force-expire everything. --- lib/dns/adb.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/dns/adb.c b/lib/dns/adb.c index fbfcd8e446..8c9b0cbeb8 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -2256,8 +2256,6 @@ dns_adb_dump(dns_adb_t *adb, FILE *f) { return; } - cleanup_names(adb, now); - cleanup_entries(adb, now); dump_adb(adb, f, false, now); rcu_read_unlock(); @@ -2291,7 +2289,19 @@ dump_adb(dns_adb_t *adb, FILE *f, bool debug, isc_stdtime_t now) { */ dns_adbname_t *adbname = NULL; cds_lfht_for_each_entry(adb->names_ht, &iter, adbname, ht_node) { + dns_adbname_ref(adbname); LOCK(&adbname->lock); + + /* + * Lazily expire stale name hooks and names while dumping. + */ + maybe_expire_namehooks(adbname, now); + if (maybe_expire_name(adbname, now)) { + UNLOCK(&adbname->lock); + dns_adbname_detach(&adbname); + continue; + } + /* * Dump the names */ @@ -2318,17 +2328,25 @@ dump_adb(dns_adb_t *adb, FILE *f, bool debug, isc_stdtime_t now) { print_find_list(f, adbname); } UNLOCK(&adbname->lock); + dns_adbname_detach(&adbname); } dns_adbentry_t *adbentry = NULL; fprintf(f, ";\n; Unassociated entries\n;\n"); cds_lfht_for_each_entry(adb->entries_ht, &iter, adbentry, ht_node) { + dns_adbentry_ref(adbentry); LOCK(&adbentry->lock); + if (maybe_expire_entry(adbentry, now)) { + UNLOCK(&adbentry->lock); + dns_adbentry_detach(&adbentry); + continue; + } if (ISC_LIST_EMPTY(adbentry->nhs)) { dump_entry(f, adb, adbentry, debug, now); } UNLOCK(&adbentry->lock); + dns_adbentry_detach(&adbentry); } }