From: Kees Monshouwer Date: Thu, 20 May 2021 14:17:13 +0000 (+0200) Subject: auth: replace or insert newly created zones in the zone cache X-Git-Tag: auth-4.5.0-alpha1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F10432%2Fhead;p=thirdparty%2Fpdns.git auth: replace or insert newly created zones in the zone cache --- 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); + } } }