]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Expand the usage of mark_ancient() helper functions
authorOndřej Surý <ondrej@isc.org>
Sun, 2 Feb 2025 12:56:37 +0000 (13:56 +0100)
committerOndřej Surý <ondrej@isc.org>
Mon, 3 Feb 2025 13:39:06 +0000 (14:39 +0100)
When the mark_ancient() helper function was introduced, couple of places
with duplicate (or almost duplicate) code was missed.  Move the
mark_ancient() function closer to the top of the file, and correctly use
it in places that mark the header as ANCIENT.

lib/dns/qpcache.c

index 64624453e03a920f8b36ef0041ce7b20c6b790ad..0b283ca042c78341c7434b1ed7da3b5f4e8a150f 100644 (file)
@@ -953,15 +953,20 @@ setttl(dns_slabheader_t *header, isc_stdtime_t newts) {
        }
 }
 
+static void
+mark_ancient(dns_slabheader_t *header) {
+       setttl(header, 0);
+       mark(header, DNS_SLABHEADERATTR_ANCIENT);
+       HEADERNODE(header)->dirty = 1;
+}
+
 /*
  * Caller must hold the node (write) lock.
  */
 static void
 expireheader(dns_slabheader_t *header, isc_rwlocktype_t *nlocktypep,
             isc_rwlocktype_t *tlocktypep, dns_expire_t reason DNS__DB_FLARG) {
-       setttl(header, 0);
-       mark(header, DNS_SLABHEADERATTR_ANCIENT);
-       HEADERNODE(header)->dirty = 1;
+       mark_ancient(header);
 
        if (isc_refcount_current(&HEADERNODE(header)->erefs) == 0) {
                qpcache_t *qpdb = (qpcache_t *)header->db;
@@ -1270,8 +1275,7 @@ check_stale_header(qpcnode_t *node, dns_slabheader_t *header,
                                }
                                dns_slabheader_destroy(&header);
                        } else {
-                               mark(header, DNS_SLABHEADERATTR_ANCIENT);
-                               HEADERNODE(header)->dirty = 1;
+                               mark_ancient(header);
                                *header_prev = header;
                        }
                } else {
@@ -2235,8 +2239,7 @@ qpcache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
                                 * non-zero.  This is so because 'node' is an
                                 * argument to the function.
                                 */
-                               mark(header, DNS_SLABHEADERATTR_ANCIENT);
-                               HEADERNODE(header)->dirty = 1;
+                               mark_ancient(header);
                        }
                } else if (EXISTS(header) && !ANCIENT(header)) {
                        if (header->type == matchtype) {
@@ -2587,13 +2590,6 @@ qpcache_destroy(dns_db_t *arg) {
        qpcache_detach(&qpdb);
 }
 
-static void
-mark_ancient(dns_slabheader_t *header) {
-       setttl(header, 0);
-       mark(header, DNS_SLABHEADERATTR_ANCIENT);
-       HEADERNODE(header)->dirty = 1;
-}
-
 /*%
  * Clean up dead nodes.  These are nodes which have no references, and
  * have no data.  They are dead but we could not or chose not to delete
@@ -3164,7 +3160,6 @@ find_header:
                        newheader->next = topheader->next;
                        newheader->down = topheader;
                        topheader->next = newheader;
-                       qpnode->dirty = 1;
                        mark_ancient(header);
                        if (sigheader != NULL) {
                                mark_ancient(sigheader);