From: Remi Gacogne Date: Tue, 7 Sep 2021 10:16:57 +0000 (+0200) Subject: dnsdist: Cleaning the connections cache is done per thread X-Git-Tag: dnsdist-1.7.0-alpha1~23^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc599d75b1d395b84d6ce3458eb071657209e791;p=thirdparty%2Fpdns.git dnsdist: Cleaning the connections cache is done per thread --- 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; };