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

lib/rplan: added ‘NO_CACHE’ flag to avoid cache lookup

this is useful if we want to prefetch or update data
in cache, it doesn’t affect the lookup of closest known
zone cut
parent 47559a1a
......@@ -97,7 +97,7 @@ static int peek(knot_layer_t *ctx, knot_pkt_t *pkt)
struct kr_request *req = ctx->data;
struct kr_rplan *rplan = &req->rplan;
struct kr_query *qry = kr_rplan_current(rplan);
if (!qry || ctx->state & (KNOT_STATE_DONE|KNOT_STATE_FAIL)) {
if (ctx->state & (KNOT_STATE_FAIL|KNOT_STATE_DONE) || (qry->flags & QUERY_NO_CACHE)) {
return ctx->state; /* Already resolved/failed */
}
if (qry->ns.addr.ip.sa_family != AF_UNSPEC) {
......
......@@ -55,11 +55,7 @@ static int loot_rr(struct kr_cache_txn *txn, knot_pkt_t *pkt, const knot_dname_t
/* 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;
}
qry->flags |= QUERY_EXPIRING;
}
/* Update packet question */
......@@ -108,7 +104,7 @@ static int peek(knot_layer_t *ctx, knot_pkt_t *pkt)
struct kr_request *req = ctx->data;
struct kr_rplan *rplan = &req->rplan;
struct kr_query *qry = kr_rplan_current(rplan);
if (!qry || ctx->state & (KNOT_STATE_FAIL|KNOT_STATE_DONE)) {
if (ctx->state & (KNOT_STATE_FAIL|KNOT_STATE_DONE) || (qry->flags & QUERY_NO_CACHE)) {
return ctx->state; /* Already resolved/failed */
}
if (qry->ns.addr.ip.sa_family != AF_UNSPEC) {
......
......@@ -36,8 +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(NO_EXPIRING, 1 << 10) /**< Do not use expiring cached records. */ \
X(NO_CACHE , 1 << 9) /**< Do not use expiring cache for lookup. */ \
X(EXPIRING , 1 << 10) /**< Query response is cached, but expiring. */ \
X(ALLOW_LOCAL, 1 << 11) /**< Allow queries to local or private address ranges. */ \
X(DNSSEC_WANT , 1 << 12) /**< Want DNSSEC secured answer. */ \
X(DNSSEC_BOGUS , 1 << 13) /**< Query response is DNSSEC bogus. */ \
......
......@@ -30,7 +30,7 @@ end
function predict.drain(ev)
local deleted = 0
for key, val in pairs(predict.queue) do
worker.resolve(string.sub(key, 2), string.byte(key), 1, kres.query.NO_EXPIRING)
worker.resolve(string.sub(key, 2), string.byte(key), 1, kres.query.NO_CACHE)
predict.queue[key] = nil
deleted = deleted + 1
if deleted >= predict.batch then
......
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