Commit a03a263e authored by Marek Vavruša's avatar Marek Vavruša

lib/cache: return records that are going to be expired next second

parent e58d1688
......@@ -152,7 +152,7 @@ int kr_cache_peek(struct kr_cache_txn *txn, uint8_t tag, const knot_dname_t *nam
} 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();
......@@ -264,7 +264,7 @@ int kr_cache_materialize(knot_rrset_t *dst, const knot_rrset_t *src, uint32_t dr
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);
......
......@@ -360,7 +360,7 @@ static void test_query(void **state)
/* 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment