chiark / gitweb /
resolved: never reuse transactions for probing that are already completed based on...
authorLennart Poettering <lennart@poettering.net>
Mon, 4 Aug 2014 23:51:40 +0000 (01:51 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 4 Aug 2014 23:52:25 +0000 (01:52 +0200)
src/resolve/resolved-dns-query.c
src/resolve/resolved-dns-scope.c
src/resolve/resolved-dns-scope.h
src/resolve/resolved-dns-zone.c

index 36cfc02..ae285ef 100644 (file)
@@ -156,7 +156,7 @@ static int dns_query_add_transaction(DnsQuery *q, DnsScope *s, DnsResourceKey *k
         } else
                 question = dns_question_ref(q->question);
 
-        t = dns_scope_find_transaction(s, question);
+        t = dns_scope_find_transaction(s, question, true);
         if (!t) {
                 r = dns_transaction_new(&t, s, question);
                 if (r < 0)
index 0f654a6..f1de9bc 100644 (file)
@@ -546,7 +546,7 @@ void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p) {
         }
 }
 
-DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsQuestion *question) {
+DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsQuestion *question, bool cache_ok) {
         DnsTransaction *t;
 
         assert(scope);
@@ -555,9 +555,19 @@ DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsQuestion *questio
         /* Try to find an ongoing transaction that is a equal or a
          * superset of the specified question */
 
-        LIST_FOREACH(transactions_by_scope, t, scope->transactions)
+        LIST_FOREACH(transactions_by_scope, t, scope->transactions) {
+
+                /* Refuse reusing transactions that completed based on
+                 * cached data instead of a real packet, if that's
+                 * requested. */
+                if (!cache_ok &&
+                    IN_SET(t->state, DNS_TRANSACTION_SUCCESS, DNS_TRANSACTION_FAILURE) &&
+                    !t->received)
+                        continue;
+
                 if (dns_question_is_superset(t->question, question) > 0)
                         return t;
+        }
 
         return NULL;
 }
index 313c617..7c18bff 100644 (file)
@@ -77,4 +77,4 @@ int dns_scope_llmnr_membership(DnsScope *s, bool b);
 
 void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p);
 
-DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsQuestion *question);
+DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsQuestion *question, bool cache_ok);
index d4e0552..649cc5c 100644 (file)
@@ -187,7 +187,7 @@ static int dns_zone_item_probe_start(DnsZoneItem *i)  {
         if (r < 0)
                 return r;
 
-        t = dns_scope_find_transaction(i->scope, question);
+        t = dns_scope_find_transaction(i->scope, question, false);
         if (!t) {
                 r = dns_transaction_new(&t, i->scope, question);
                 if (r < 0)