Skip to content
Snippets Groups Projects
Commit 72922a43 authored by Marek Vavruša's avatar Marek Vavruša
Browse files

lib: cleanup

parent c25d6ce1
No related branches found
No related tags found
No related merge requests found
......@@ -67,15 +67,14 @@ static int loot_cache_pkt(struct kr_cache_txn *txn, knot_pkt_t *pkt, const knot_
/* Copy answer, keep the original message id */
if (entry->count <= pkt->max_size) {
/* Keep original header and copy cached */
uint8_t header[KNOT_WIRE_HEADER_SIZE];
memcpy(header, pkt->wire, sizeof(header));
uint16_t msgid = knot_wire_get_id(pkt->wire);
/* Copy and reparse */
knot_pkt_clear(pkt);
memcpy(pkt->wire, entry->data, entry->count);
pkt->size = entry->count;
knot_pkt_parse(pkt, 0);
/* Restore header bits */
knot_wire_set_id(pkt->wire, knot_wire_get_id(header));
knot_wire_set_id(pkt->wire, msgid);
}
/* Adjust TTL in records. */
......
......@@ -36,7 +36,9 @@ extern void _cleanup_fclose(FILE **p);
/** @internal Fast packet reset. */
#define KR_PKT_RECYCLE(pkt) do { \
(pkt)->parsed = (pkt)->size = KNOT_WIRE_HEADER_SIZE; \
(pkt)->current = KNOT_ANSWER; \
(pkt)->rrset_count = 0; \
(pkt)->size = KNOT_WIRE_HEADER_SIZE; \
knot_pkt_parse_question((pkt)); \
} while (0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment