]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Move ADB TTL-based cleanup into dump_adb()
authorOndřej Surý <ondrej@isc.org>
Sat, 14 Mar 2026 08:45:05 +0000 (09:45 +0100)
committerOndřej Surý <ondrej@isc.org>
Mon, 30 Mar 2026 19:46:44 +0000 (21:46 +0200)
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

index fbfcd8e446b1be5c84c544ab67dab3885bb21265..8c9b0cbeb8f123ae02629b35eee2e95260ffab1b 100644 (file)
@@ -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);
        }
 }