From c493eea6f0b8cdd4bcc16263208463ffae91c7a0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Vavru=C5=A1a?= Date: Thu, 28 May 2015 01:26:07 +0200 Subject: [PATCH] lib/caches: lookup direct matches only since the zone cut is looked up after layers now, it is pointless to search for minimized names from cache, since this is the same operation as searching for a zone cut --- lib/layer/pktcache.c | 16 +++------------- lib/layer/rrcache.c | 16 +++------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/lib/layer/pktcache.c b/lib/layer/pktcache.c index e45ac1351..15c85de7d 100644 --- a/lib/layer/pktcache.c +++ b/lib/layer/pktcache.c @@ -90,23 +90,13 @@ static int loot_cache_pkt(struct kr_cache_txn *txn, knot_pkt_t *pkt, const knot_ return ret; } -/** @internal Try to find a shortcut directly to searched packet, otherwise try to find minimised QNAME. */ +/** @internal Try to find a shortcut directly to searched packet. */ static int loot_cache(struct kr_cache_txn *txn, knot_pkt_t *pkt, uint8_t tag, struct kr_query *qry) { uint32_t timestamp = qry->timestamp.tv_sec; const knot_dname_t *qname = qry->sname; uint16_t rrtype = qry->stype; - int ret = loot_cache_pkt(txn, pkt, qname, rrtype, tag, timestamp); - if (ret == 0) { /* Signalize minimisation disabled */ - qry->flags |= QUERY_NO_MINIMIZE; - } else { /* Retry with minimised name */ - qname = knot_pkt_qname(pkt); - rrtype = knot_pkt_qtype(pkt); - if (!knot_dname_is_equal(qname, qry->sname)) { - ret = loot_cache_pkt(txn, pkt, qname, rrtype, tag, timestamp); - } - } - return ret; + return loot_cache_pkt(txn, pkt, qname, rrtype, tag, timestamp); } static int peek(knot_layer_t *ctx, knot_pkt_t *pkt) @@ -134,7 +124,7 @@ static int peek(knot_layer_t *ctx, knot_pkt_t *pkt) kr_cache_txn_abort(&txn); if (ret == 0) { DEBUG_MSG("=> satisfied from cache\n"); - qry->flags |= QUERY_CACHED; + qry->flags |= QUERY_CACHED|QUERY_NO_MINIMIZE; pkt->parsed = pkt->size; knot_wire_set_qr(pkt->wire); return KNOT_STATE_DONE; diff --git a/lib/layer/rrcache.c b/lib/layer/rrcache.c index b907760b0..821da0688 100644 --- a/lib/layer/rrcache.c +++ b/lib/layer/rrcache.c @@ -73,23 +73,13 @@ static int loot_cache_set(struct kr_cache_txn *txn, knot_pkt_t *pkt, const knot_ return ret; } -/** @internal Try to find a shortcut directly to searched record, otherwise try to find minimised QNAME. */ +/** @internal Try to find a shortcut directly to searched record. */ static int loot_cache(struct kr_cache_txn *txn, knot_pkt_t *pkt, struct kr_query *qry) { const knot_dname_t *qname = qry->sname; uint16_t rrclass = qry->sclass; uint16_t rrtype = qry->stype; - int ret = loot_cache_set(txn, pkt, qname, rrclass, rrtype, qry); - if (ret == 0) { /* Signalize minimisation disabled */ - qry->flags |= QUERY_NO_MINIMIZE; - } else { /* Retry with minimised name */ - qname = knot_pkt_qname(pkt); - rrtype = knot_pkt_qtype(pkt); - if (!knot_dname_is_equal(qname, qry->sname)) { - ret = loot_cache_set(txn, pkt, qname, rrclass, rrtype, qry); - } - } - return ret; + return loot_cache_set(txn, pkt, qname, rrclass, rrtype, qry); } static int peek(knot_layer_t *ctx, knot_pkt_t *pkt) @@ -115,7 +105,7 @@ static int peek(knot_layer_t *ctx, knot_pkt_t *pkt) kr_cache_txn_abort(&txn); if (ret == 0) { DEBUG_MSG("=> satisfied from cache\n"); - qry->flags |= QUERY_CACHED; + qry->flags |= QUERY_CACHED|QUERY_NO_MINIMIZE; pkt->parsed = pkt->size; knot_wire_set_qr(pkt->wire); knot_wire_set_aa(pkt->wire); -- 2.47.3