summaryrefslogtreecommitdiffstats
path: root/lib/cache/entry_pkt.c
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2020-07-22 10:29:16 +0200
committerVladimír Čunát <vladimir.cunat@nic.cz>2023-06-12 10:22:42 +0200
commit7ebe70eff3dd6a2eacd7290c56d1e8ddc19babfc (patch)
treeabca7d562c4932af1cbd5a6cd942bc112e27d6eb /lib/cache/entry_pkt.c
parentci: reduce exceptions specific to manager branch (diff)
downloadknot-resolver-7ebe70eff3dd6a2eacd7290c56d1e8ddc19babfc.tar.xz
knot-resolver-7ebe70eff3dd6a2eacd7290c56d1e8ddc19babfc.zip
lib/cache: simplify passing qry/req parameters
- kr_layer_t isn't really useful in the inner functions (it's mainly useful through ->state when returning from layer) - kr_query seems a little more suitable to pass than kr_request
Diffstat (limited to 'lib/cache/entry_pkt.c')
-rw-r--r--lib/cache/entry_pkt.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/cache/entry_pkt.c b/lib/cache/entry_pkt.c
index 884bfaa8..9499b69a 100644
--- a/lib/cache/entry_pkt.c
+++ b/lib/cache/entry_pkt.c
@@ -125,12 +125,9 @@ void stash_pkt(const knot_pkt_t *pkt, const struct kr_query *qry,
}
-int answer_from_pkt(kr_layer_t *ctx, knot_pkt_t *pkt, uint16_t type,
+int answer_from_pkt(struct kr_query *qry, knot_pkt_t *pkt, uint16_t type,
const struct entry_h *eh, const void *eh_bound, uint32_t new_ttl)
{
- struct kr_request *req = ctx->req;
- struct kr_query *qry = req->current_query;
-
const uint16_t msgid = knot_wire_get_id(pkt->wire);
/* Ensure the wire buffer is large enough. Strategy: fit and at least double. */
@@ -139,8 +136,8 @@ int answer_from_pkt(kr_layer_t *ctx, knot_pkt_t *pkt, uint16_t type,
if (pkt_len > pkt->max_size) {
pkt->max_size = MIN(KNOT_WIRE_MAX_PKTSIZE,
MAX(pkt->max_size * 2, pkt_len));
- mm_free(&ctx->req->pool, pkt->wire); /* no-op, but... */
- pkt->wire = mm_alloc(&ctx->req->pool, pkt->max_size);
+ mm_free(&qry->request->pool, pkt->wire); /* no-op, but... */
+ pkt->wire = mm_alloc(&qry->request->pool, pkt->max_size);
pkt->compr.wire = pkt->wire;
/* TODO: ^^ nicer way how to replace knot_pkt_t::wire ? */
}