summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-scope.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-05 01:51:40 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-05 01:52:25 +0200
commitdc4d47e2c79aafa3ef646e32ff3422c4ce935c1b (patch)
tree7d8fdea3f49ea941ca6d3860dc88cd6248586724 /src/resolve/resolved-dns-scope.c
parent4d926a69bc27b8fbd4891bb10c03336bd8d93b7a (diff)
resolved: never reuse transactions for probing that are already completed based on cached data
Diffstat (limited to 'src/resolve/resolved-dns-scope.c')
-rw-r--r--src/resolve/resolved-dns-scope.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
index 0f654a6102..f1de9bc2eb 100644
--- a/src/resolve/resolved-dns-scope.c
+++ b/src/resolve/resolved-dns-scope.c
@@ -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;
}