From: Ondřej Surý Date: Sat, 14 Mar 2026 08:45:05 +0000 (+0100) Subject: Move ADB TTL-based cleanup into dump_adb() X-Git-Tag: v9.21.21~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03ff80a1f79deedfb597a070c3bfbff6d2c67b7d;p=thirdparty%2Fbind9.git 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. --- diff --git a/lib/dns/adb.c b/lib/dns/adb.c index fbfcd8e446b..8c9b0cbeb8f 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); } }