From 069ea15204b8d1e2a9f48e85e70b51c4f03032ef Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 25 Oct 2012 14:29:10 +1100 Subject: [PATCH] 3405. [bug] Handle time going backwards in acache. [RT #31253] Squashed commit of the following: commit fbf4c8fe2644c101bac870360d3f2c159a90f203 Author: Mark Andrews Date: Wed Oct 24 14:43:14 2012 +1100 remove INSIST and handle time going backwards --- CHANGES | 2 ++ lib/dns/acache.c | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index e5a681e8b9..06db5c5974 100644 --- 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] diff --git a/lib/dns/acache.c b/lib/dns/acache.c index 2ad4981de6..0c96010c2d 100644 --- a/lib/dns/acache.c +++ b/lib/dns/acache.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -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;