summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-query.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-26 22:51:35 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-27 00:03:39 +0100
commitae6a4bbf318e197813227e50c245a00de03784a2 (patch)
tree94a1761cfa4e445ed820e2cccd01dde7d2949e55 /src/resolve/resolved-dns-query.c
parentb05f5ae7c5a95f44a59e5d2251879d0ef2af9cb2 (diff)
resolved: store just the DnsAnswer instead of a DnsPacket as answer in DnsTransaction objects
Previously we'd only store the DnsPacket in the DnsTransaction, and the DnsQuery would then take the DnsPacket's DnsAnswer and return it. With this change we already pull the DnsAnswer out inside the transaction. We still store the DnsPacket in the transaction, if we have it, since we still need to determine from which peer a response originates, to implement caching properly. However, the DnsQuery logic doesn't care anymore for the packet, it now only looks at answers and rcodes from the successfuly candidate. This also has the benefit of unifying how we propagate incoming packets, data from the local zone or the local cache.
Diffstat (limited to 'src/resolve/resolved-dns-query.c')
-rw-r--r--src/resolve/resolved-dns-query.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c
index b84f5bf0f3..fe99caff37 100644
--- a/src/resolve/resolved-dns-query.c
+++ b/src/resolve/resolved-dns-query.c
@@ -998,17 +998,9 @@ static void dns_query_accept(DnsQuery *q, DnsQueryCandidate *c) {
case DNS_TRANSACTION_SUCCESS: {
/* We found a successfuly reply, merge it into the answer */
- DnsAnswer *merged, *a;
-
- if (t->received) {
- q->answer_rcode = DNS_PACKET_RCODE(t->received);
- a = t->received->answer;
- } else {
- q->answer_rcode = t->cached_rcode;
- a = t->cached;
- }
+ DnsAnswer *merged;
- merged = dns_answer_merge(q->answer, a);
+ merged = dns_answer_merge(q->answer, t->answer);
if (!merged) {
dns_query_complete(q, DNS_TRANSACTION_RESOURCES);
return;
@@ -1016,6 +1008,7 @@ static void dns_query_accept(DnsQuery *q, DnsQueryCandidate *c) {
dns_answer_unref(q->answer);
q->answer = merged;
+ q->answer_rcode = t->answer_rcode;
state = DNS_TRANSACTION_SUCCESS;
break;
@@ -1034,14 +1027,8 @@ static void dns_query_accept(DnsQuery *q, DnsQueryCandidate *c) {
if (state != DNS_TRANSACTION_SUCCESS) {
dns_answer_unref(q->answer);
-
- if (t->received) {
- q->answer = dns_answer_ref(t->received->answer);
- q->answer_rcode = DNS_PACKET_RCODE(t->received);
- } else {
- q->answer = dns_answer_ref(t->cached);
- q->answer_rcode = t->cached_rcode;
- }
+ q->answer = dns_answer_ref(t->answer);
+ q->answer_rcode = t->answer_rcode;
state = t->state;
}