]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Cleaning the connections cache is done per thread
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 7 Sep 2021 10:16:57 +0000 (12:16 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 13 Sep 2021 13:34:34 +0000 (15:34 +0200)
pdns/dnsdistdist/dnsdist-nghttp2.cc
pdns/dnsdistdist/dnsdist-tcp-downstream.cc
pdns/dnsdistdist/dnsdist-tcp-downstream.hh

index 033d043c7469262eac1e2b119abfa7ae1873c112..dbee3d8c6bc3572819fd1444900bfc6c2dcdb3be 100644 (file)
@@ -138,8 +138,8 @@ public:
 
 private:
   static thread_local map<boost::uuids::uuid, std::deque<std::shared_ptr<DoHConnectionToBackend>>> t_downstreamConnections;
+  static thread_local time_t t_nextCleanup;
   static size_t s_maxCachedConnectionsPerDownstream;
-  static time_t s_nextCleanup;
   static uint16_t s_cleanupInterval;
 };
 
@@ -807,8 +807,8 @@ DoHConnectionToBackend::DoHConnectionToBackend(std::shared_ptr<DownstreamState>
 }
 
 thread_local map<boost::uuids::uuid, std::deque<std::shared_ptr<DoHConnectionToBackend>>> DownstreamDoHConnectionsManager::t_downstreamConnections;
+thread_local time_t DownstreamDoHConnectionsManager::t_nextCleanup{0};
 size_t DownstreamDoHConnectionsManager::s_maxCachedConnectionsPerDownstream{10};
-time_t DownstreamDoHConnectionsManager::s_nextCleanup{0};
 uint16_t DownstreamDoHConnectionsManager::s_cleanupInterval{60};
 
 size_t DownstreamDoHConnectionsManager::clear()
@@ -883,8 +883,8 @@ std::shared_ptr<DoHConnectionToBackend> DownstreamDoHConnectionsManager::getConn
 
   auto backendId = ds->getID();
 
-  if (s_cleanupInterval > 0 && (s_nextCleanup == 0 || s_nextCleanup <= now.tv_sec)) {
-    s_nextCleanup = now.tv_sec + s_cleanupInterval;
+  if (s_cleanupInterval > 0 && (t_nextCleanup == 0 || t_nextCleanup <= now.tv_sec)) {
+    t_nextCleanup = now.tv_sec + s_cleanupInterval;
     //cerr<<"cleaning up"<<endl;
     cleanupClosedConnections(now);
   }
index 5935b06448afa9bb9890383d4f459eee87d450d8..59c065d3384ff987c3b9e9129351757c19d6a02a 100644 (file)
@@ -721,8 +721,8 @@ std::shared_ptr<TCPConnectionToBackend> DownstreamConnectionsManager::getConnect
 
   auto backendId = ds->getID();
 
-  if (s_cleanupInterval > 0 && (s_nextCleanup == 0 || s_nextCleanup <= now.tv_sec)) {
-    s_nextCleanup = now.tv_sec + s_cleanupInterval;
+  if (s_cleanupInterval > 0 && (t_nextCleanup == 0 || t_nextCleanup <= now.tv_sec)) {
+    t_nextCleanup = now.tv_sec + s_cleanupInterval;
     cleanupClosedTCPConnections(now);
   }
 
@@ -832,6 +832,6 @@ void setMaxCachedTCPConnectionsPerDownstream(size_t max)
 }
 
 thread_local map<boost::uuids::uuid, std::deque<std::shared_ptr<TCPConnectionToBackend>>> DownstreamConnectionsManager::t_downstreamConnections;
+thread_local time_t DownstreamConnectionsManager::t_nextCleanup{0};
 size_t DownstreamConnectionsManager::s_maxCachedConnectionsPerDownstream{10};
-time_t DownstreamConnectionsManager::s_nextCleanup{0};
 uint16_t DownstreamConnectionsManager::s_cleanupInterval{60};
index 2d79a908250fa755643ee8077d2a328f3c6baf24..249596b1b8b6be69cea6f181ed4573c005c97931 100644 (file)
@@ -249,7 +249,7 @@ public:
 
 private:
   static thread_local map<boost::uuids::uuid, std::deque<std::shared_ptr<TCPConnectionToBackend>>> t_downstreamConnections;
+  static thread_local time_t t_nextCleanup;
   static size_t s_maxCachedConnectionsPerDownstream;
-  static time_t s_nextCleanup;
   static uint16_t s_cleanupInterval;
 };