From ed9bd57ce8c1caa1a45048834b41e6b9627819a4 Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Thu, 20 May 2021 16:17:13 +0200 Subject: [PATCH] auth: replace or insert newly created zones in the zone cache --- pdns/auth-zonecache.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pdns/auth-zonecache.cc b/pdns/auth-zonecache.cc index c4c6d6d22c..bdac5ed81a 100644 --- a/pdns/auth-zonecache.cc +++ b/pdns/auth-zonecache.cc @@ -101,7 +101,13 @@ void AuthZoneCache::replace(const vector>& zone_indices) CacheValue val; val.zoneId = tup.get<1>(); auto& mc = newMaps[getMapIndex(zone)]; - mc.d_map.emplace(zone, val); + auto iter = mc.d_map.find(zone); + if (iter != mc.d_map.end()) { + iter->second = std::move(val); + } + else { + mc.d_map.emplace(zone, val); + } } { @@ -149,7 +155,13 @@ void AuthZoneCache::add(const DNSName& zone, const int zoneId) { auto& mc = d_maps[mapIndex]; WriteLock mcLock(mc.d_mut); - mc.d_map.emplace(zone, val); + auto iter = mc.d_map.find(zone); + if (iter != mc.d_map.end()) { + iter->second = std::move(val); + } + else { + mc.d_map.emplace(zone, val); + } } } -- 2.47.2