summaryrefslogtreecommitdiff
path: root/src/resolve
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-12-18 19:19:56 +0100
committerLennart Poettering <lennart@poettering.net>2015-12-18 19:19:56 +0100
commit1f97052fe0e90781b6e4caac0ecd104bd2bf54e6 (patch)
tree154c9f8bfffb45378d14e9e6a53f37e2218f33aa /src/resolve
parent950b692bfbabf01e92f912450b0c76265c99ae43 (diff)
resolved: optimize dns_cache_remove() a bit
Diffstat (limited to 'src/resolve')
-rw-r--r--src/resolve/resolved-dns-cache.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c
index 65eff7fda6..2e3090b32a 100644
--- a/src/resolve/resolved-dns-cache.c
+++ b/src/resolve/resolved-dns-cache.c
@@ -101,18 +101,21 @@ void dns_cache_flush(DnsCache *c) {
}
static bool dns_cache_remove(DnsCache *c, DnsResourceKey *key) {
- DnsCacheItem *i;
- bool exist = false;
+ DnsCacheItem *first, *i, *n;
assert(c);
assert(key);
- while ((i = hashmap_get(c->by_key, key))) {
- dns_cache_item_remove_and_free(c, i);
- exist = true;
+ first = hashmap_remove(c->by_key, key);
+ if (!first)
+ return false;
+
+ LIST_FOREACH_SAFE(by_key, i, n, first) {
+ prioq_remove(c->by_expiry, i, &i->prioq_idx);
+ dns_cache_item_free(i);
}
- return exist;
+ return true;
}
static void dns_cache_make_space(DnsCache *c, unsigned add) {