]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Clarify what DynBlockMaintenance::s_topsMutex protects 9756/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 1 Dec 2020 14:08:52 +0000 (15:08 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 1 Dec 2020 14:08:52 +0000 (15:08 +0100)
pdns/dnsdist-dynblocks.hh
pdns/dnsdistdist/dnsdist-dynblocks.cc

index 87027a47ce1f9bf4cbf5a975338d97291a54a50e..8f031f457a09148c1cbe24c65e6c208aa82d4c51 100644 (file)
@@ -394,6 +394,8 @@ private:
     std::map<std::string, std::list<std::pair<DNSName, unsigned int>>> smtData;
   };
 
+  /* Protects s_topNMGsByReason and s_topSMTsByReason. s_metricsData should only be accessed
+     by the dynamic blocks maintenance thread so it does not need a lock. */
   static std::mutex s_topsMutex;
   // need N+1 datapoints to be able to do the diff after a collection point has been reached
   static std::list<MetricsSnapshot> s_metricsData;
index 900a25cfafc8c723d54c59de468782ee429831d4..574cd4c4c2fc66501307736a61a97b74c74904fd 100644 (file)
@@ -475,13 +475,10 @@ void DynBlockMaintenance::collectMetrics()
   snapshot.smtData = getTopSuffixes(s_topN * 5);
   snapshot.nmgData = getTopNetmasks(s_topN * 5);
 
-  {
-    std::lock_guard<std::mutex> lock(s_topsMutex);
-    if (s_metricsData.size() >= 7) {
-      s_metricsData.pop_front();
-    }
-    s_metricsData.push_back(std::move(snapshot));
+  if (s_metricsData.size() >= 7) {
+    s_metricsData.pop_front();
   }
+  s_metricsData.push_back(std::move(snapshot));
 }
 
 void DynBlockMaintenance::generateMetrics()