From 4bb0ef831b7854b765abdaf5ce89fca7ada38d5f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Vavrus=CC=8Ca?= Date: Sun, 19 Jul 2015 00:56:03 +0200 Subject: [PATCH] lib/rplan: ability to refetch expiring queries --- lib/layer/rrcache.c | 14 +++++++++----- lib/rplan.h | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/layer/rrcache.c b/lib/layer/rrcache.c index 65b0596a5..9d017caf6 100644 --- a/lib/layer/rrcache.c +++ b/lib/layer/rrcache.c @@ -52,17 +52,21 @@ static int loot_rr(struct kr_cache_txn *txn, knot_pkt_t *pkt, const knot_dname_t return ret; } + /* Mark as expiring if it has less than 1% TTL (or less than 5s) */ + if (is_expiring(&cache_rr, drift)) { + if (qry->flags & QUERY_NO_EXPIRING) { + return kr_error(ENOENT); + } else { + qry->flags |= QUERY_EXPIRING; + } + } + /* Update packet question */ if (!knot_dname_is_equal(knot_pkt_qname(pkt), name)) { KR_PKT_RECYCLE(pkt); knot_pkt_put_question(pkt, qry->sname, qry->sclass, qry->stype); } - /* Mark as expiring if it has less than 1% TTL (or less than 5s) */ - if (is_expiring(&cache_rr, drift)) { - qry->flags |= QUERY_EXPIRING; - } - /* Update packet answer */ knot_rrset_t rr_copy; ret = kr_cache_materialize(&rr_copy, &cache_rr, drift, &pkt->mm); diff --git a/lib/rplan.h b/lib/rplan.h index a459f4c5b..96785a6f7 100644 --- a/lib/rplan.h +++ b/lib/rplan.h @@ -36,7 +36,8 @@ X(AWAIT_CUT , 1 << 6) /**< Query is waiting for zone cut lookup */ \ X(SAFEMODE , 1 << 7) /**< Don't use fancy stuff (EDNS...) */ \ X(CACHED , 1 << 8) /**< Query response is cached. */ \ - X(EXPIRING , 1 << 9) /**< Query response is cached, but expiring. */ + X(EXPIRING , 1 << 9) /**< Query response is cached, but expiring. */ \ + X(NO_EXPIRING, 1 << 10) /**< Do not use expiring cached records. */ \ /** Query flags */ enum kr_query_flag { -- 2.47.2