summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-transaction.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-01 18:09:07 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-01 18:10:01 +0200
commit2c27fbca2d88214bd305272308a370a962818f1e (patch)
treeae09b9ca13041c3eab777c1dd596e4224a879385 /src/resolve/resolved-dns-transaction.c
parent5cb36f41f01cf4b1f4395abfffd1b33116591e58 (diff)
resolved: flush cache each time we change to a different DNS server
Diffstat (limited to 'src/resolve/resolved-dns-transaction.c')
-rw-r--r--src/resolve/resolved-dns-transaction.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
index faa1de9143..48da432a12 100644
--- a/src/resolve/resolved-dns-transaction.c
+++ b/src/resolve/resolved-dns-transaction.c
@@ -465,12 +465,19 @@ int dns_transaction_go(DnsTransaction *t) {
t->cached = dns_answer_unref(t->cached);
t->cached_rcode = 0;
- /* First, let's try the cache */
+ /* Before trying the cache, let's make sure we figured out a
+ * server to use. Should this cause a change of server this
+ * might flush the cache. */
+ dns_scope_get_dns_server(t->scope);
+
+ /* Let's then prune all outdated entries */
dns_cache_prune(&t->scope->cache);
+
r = dns_cache_lookup(&t->scope->cache, t->question, &t->cached_rcode, &t->cached);
if (r < 0)
return r;
if (r > 0) {
+ log_debug("Cache hit!");
if (t->cached_rcode == DNS_RCODE_SUCCESS)
dns_transaction_complete(t, DNS_TRANSACTION_SUCCESS);
else
@@ -478,6 +485,8 @@ int dns_transaction_go(DnsTransaction *t) {
return 0;
}
+ log_debug("Cache miss!");
+
/* Otherwise, we need to ask the network */
r = dns_transaction_make_packet(t);
if (r == -EDOM) {