]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
statbag: when redeclaring a key, reset to 0 instead of reallocating
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 20 Aug 2020 13:10:59 +0000 (15:10 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 20 Aug 2020 13:10:59 +0000 (15:10 +0200)
pdns/statbag.cc

index 110287ae0831879ce9a2d3e805652d925bb27848..0876b2732398adaeb72b230c001f099c72aa5979 100644 (file)
@@ -105,6 +105,11 @@ StatType StatBag::getStatType(const string &item)
 
 void StatBag::declare(const string &key, const string &descrip, StatType statType)
 {
+  if(d_stats.count(key)) {
+    *d_stats[key] = 0;
+    return;
+  }
+
   auto i=make_unique<AtomicCounter>(0);
   d_stats[key]=std::move(i);
   d_keyDescrips[key]=descrip;