]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib: cleanup
authorMarek Vavruša <marek.vavrusa@nic.cz>
Fri, 3 Jul 2015 22:01:12 +0000 (00:01 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Fri, 3 Jul 2015 22:01:12 +0000 (00:01 +0200)
lib/layer/pktcache.c
lib/utils.h

index b1453f1ff6b9968a0cd98e98f7cca58f16455065..4cac85a98e9110530a403398676dbe143e2e3fc3 100644 (file)
@@ -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. */
index e26fedd763dd11e17b39dd377192041df5cefa1a..405be2c2f9b60c6c78edc70b81d35aea31d0e067 100644 (file)
@@ -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)