]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3405. [bug] Handle time going backwards in acache. [RT #31253]
authorMark Andrews <marka@isc.org>
Thu, 25 Oct 2012 03:29:10 +0000 (14:29 +1100)
committerMark Andrews <marka@isc.org>
Thu, 25 Oct 2012 03:29:10 +0000 (14:29 +1100)
Squashed commit of the following:

commit fbf4c8fe2644c101bac870360d3f2c159a90f203
Author: Mark Andrews <marka@isc.org>
Date:   Wed Oct 24 14:43:14 2012 +1100

    remove INSIST and handle time going backwards

CHANGES
lib/dns/acache.c

diff --git a/CHANGES b/CHANGES
index 7a5194465a8bcad20a5a670a20fd26522a91fa49..8046ecfaebe389fe28c2046bfc2b17dc2b0bd7dc 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+3405.  [bug]           Handle time going backwards in acache. [RT #31253]
+
 3404.  [bug]           dnssec-signzone: When re-signing a zone, remove
                        RRSIG and NSEC records from nodes that used to be 
                        in-zone but are now below a zone cut. [RT #31556]
index 2ad4981de69b7047550b647a8c1cb32d83429fdf..0c96010c2de725721e81299a1508fb6e71f3b243 100644 (file)
@@ -27,6 +27,7 @@
 #include <isc/random.h>
 #include <isc/refcount.h>
 #include <isc/rwlock.h>
+#include <isc/serial.h>
 #include <isc/task.h>
 #include <isc/time.h>
 #include <isc/timer.h>
@@ -776,10 +777,14 @@ entry_stale(acache_cleaner_t *cleaner, dns_acacheentry_t *entry,
         * use and the cleaning interval.
         */
        if (cleaner->overmem) {
-               unsigned int passed =
-                       now32 - entry->lastused; /* <= interval */
+               unsigned int passed;
                isc_uint32_t val;
 
+               if (isc_serial_ge(now32, entry->lastused))
+                       passed = now32 - entry->lastused; /* <= interval */
+               else
+                       passed = 0;
+
                if (passed > interval / 2)
                        return (ISC_TRUE);
                isc_random_get(&val);
@@ -825,8 +830,10 @@ acache_incremental_cleaning_action(isc_task_t *task, isc_event_t *event) {
 
        entry = cleaner->current_entry;
        isc_stdtime_convert32(cleaner->last_cleanup_time, &last32);
-       INSIST(now32 > last32);
-       interval = now32 - last32;
+       if (isc_serial_ge(now32, last32))
+               interval = now32 - last32;
+       else
+               interval = 0;
 
        while (n_entries-- > 0) {
                isc_boolean_t is_stale = ISC_FALSE;