]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: replace or insert newly created zones in the zone cache 10432/head
authorKees Monshouwer <mind04@monshouwer.org>
Thu, 20 May 2021 14:17:13 +0000 (16:17 +0200)
committermind04 <mind04@monshouwer.org>
Fri, 21 May 2021 07:45:54 +0000 (09:45 +0200)
pdns/auth-zonecache.cc

index c4c6d6d22ca76308262535aed95bf2ffe9b3031d..bdac5ed81ab5d3eb15f2a105921d70c0f5f7dee3 100644 (file)
@@ -101,7 +101,13 @@ void AuthZoneCache::replace(const vector<tuple<DNSName, int>>& 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);
+    }
   }
 }