From: Marek VavruĊĦa Date: Mon, 6 Jul 2015 00:02:55 +0000 (+0200) Subject: layer/rrcache: cache authority only if chasing referral/cname X-Git-Tag: v1.0.0-beta1~88^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=378b43d77864331e584bdfae98a207b904252619;p=thirdparty%2Fknot-resolver.git layer/rrcache: cache authority only if chasing referral/cname --- 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 */