From: Marek VavruĊĦa Date: Mon, 9 Feb 2015 16:15:43 +0000 (+0100) Subject: cache: fixed drift when current time <= than cached X-Git-Tag: v1.0.0-beta1~335^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=573b679fbed425a0a0ef2dfea3dadc45bd4d6e7e;p=thirdparty%2Fknot-resolver.git cache: fixed drift when current time <= than cached --- diff --git a/lib/cache.c b/lib/cache.c index 704bfcf05..1c2ef64e0 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -115,8 +115,14 @@ int kr_cache_peek(namedb_txn_t *txn, knot_rrset_t *rr, uint32_t *timestamp) rr->rrs.rr_count = found_rr->count; rr->rrs.data = found_rr->data; - /* No time constraint or current timestamp */ - if (timestamp == NULL || *timestamp <= found_rr->timestamp) { + /* No time constraint */ + if (timestamp == NULL) { + return KNOT_EOK; + } + + /* John Connor record cached from the future. */ + if (*timestamp < found_rr->timestamp) { + *timestamp = 0; return KNOT_EOK; }