} else {
/* Check if the record is still valid. */
uint32_t drift = *timestamp - found->timestamp;
- if (drift < found->ttl) {
+ if (drift <= found->ttl) {
*timestamp = drift;
txn->owner->stats.hit += 1;
return kr_ok();
knot_rdata_t *rd = knot_rdataset_at(&src->rrs, 0);
knot_rdata_t *rd_dst = NULL;
for (uint16_t i = 0; i < src->rrs.rr_count; ++i) {
- if (knot_rdata_ttl(rd) > drift) {
+ if (knot_rdata_ttl(rd) >= drift) {
/* Append record */
if (knot_rdataset_add(&dst->rrs, rd, mm) != 0) {
knot_rrset_clear(dst, mm);
/* Test cache read (simulate aged entry) */
static void test_query_aged(void **state)
{
- uint32_t timestamp = CACHE_TIME + CACHE_TTL;
+ uint32_t timestamp = CACHE_TIME + CACHE_TTL + 1;
knot_rrset_t cache_rr;
knot_rrset_init(&cache_rr, global_rr.owner, global_rr.type, global_rr.rclass);