From 378b43d77864331e584bdfae98a207b904252619 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Vavru=C5=A1a?= Date: Mon, 6 Jul 2015 02:02:55 +0200 Subject: [PATCH] layer/rrcache: cache authority only if chasing referral/cname --- lib/layer/rrcache.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/layer/rrcache.c b/lib/layer/rrcache.c index 9cf0568d7..d2db8a5e1 100644 --- a/lib/layer/rrcache.c +++ b/lib/layer/rrcache.c @@ -248,10 +248,15 @@ static int stash(knot_layer_t *ctx, knot_pkt_t *pkt) stash.malloc = (map_alloc_f) mm_alloc; stash.free = (map_free_f) mm_free; stash.baton = rplan->pool; - int ret = stash_authority(qry, pkt, &stash, rplan->pool); - if (ret == 0 && knot_wire_get_aa(pkt->wire)) { + int ret = 0; + bool is_auth = knot_wire_get_aa(pkt->wire); + if (is_auth) { ret = stash_answer(qry, pkt, &stash, rplan->pool); } + /* Cache authority only if chasing referral/cname chain */ + if (!is_auth || qry != HEAD(rplan->pending)) { + ret = stash_authority(qry, pkt, &stash, rplan->pool); + } /* Cache stashed records */ if (ret == 0) { /* Open write transaction */ -- 2.47.2