From cc599d75b1d395b84d6ce3458eb071657209e791 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 7 Sep 2021 12:16:57 +0200 Subject: [PATCH] dnsdist: Cleaning the connections cache is done per thread --- pdns/dnsdistdist/dnsdist-nghttp2.cc | 8 ++++---- pdns/dnsdistdist/dnsdist-tcp-downstream.cc | 6 +++--- pdns/dnsdistdist/dnsdist-tcp-downstream.hh | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pdns/dnsdistdist/dnsdist-nghttp2.cc b/pdns/dnsdistdist/dnsdist-nghttp2.cc index 033d043c74..dbee3d8c6b 100644 --- a/pdns/dnsdistdist/dnsdist-nghttp2.cc +++ b/pdns/dnsdistdist/dnsdist-nghttp2.cc @@ -138,8 +138,8 @@ public: private: static thread_local map>> 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 } thread_local map>> 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 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"< 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>> 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}; diff --git a/pdns/dnsdistdist/dnsdist-tcp-downstream.hh b/pdns/dnsdistdist/dnsdist-tcp-downstream.hh index 2d79a90825..249596b1b8 100644 --- a/pdns/dnsdistdist/dnsdist-tcp-downstream.hh +++ b/pdns/dnsdistdist/dnsdist-tcp-downstream.hh @@ -249,7 +249,7 @@ public: private: static thread_local map>> t_downstreamConnections; + static thread_local time_t t_nextCleanup; static size_t s_maxCachedConnectionsPerDownstream; - static time_t s_nextCleanup; static uint16_t s_cleanupInterval; }; -- 2.47.2