]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Tidy rec-tcpout.??
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 18 Feb 2025 09:53:44 +0000 (10:53 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 4 Sep 2025 09:03:56 +0000 (11:03 +0200)
pdns/recursordist/rec-tcpout.cc
pdns/recursordist/rec-tcpout.hh

index 8b65110e0fb0af41396e5f650ca99320742b3875..46937018353987e69ed046d3a7098e8cb859f236 100644 (file)
@@ -51,33 +51,33 @@ void TCPOutConnectionManager::cleanup(const struct timeval& now)
   }
 }
 
-void TCPOutConnectionManager::store(const struct timeval& now, const ComboAddress& ip, Connection&& connection)
+void TCPOutConnectionManager::store(const struct timeval& now, const ComboAddress& remoteAddress, Connection&& connection)
 {
   ++connection.d_numqueries;
   if (s_maxQueries > 0 && connection.d_numqueries >= s_maxQueries) {
     return;
   }
 
-  if (d_idle_connections.size() >= s_maxIdlePerThread || d_idle_connections.count(ip) >= s_maxIdlePerAuth) {
+  if (d_idle_connections.size() >= s_maxIdlePerThread || d_idle_connections.count(remoteAddress) >= s_maxIdlePerAuth) {
     cleanup(now);
   }
 
   if (d_idle_connections.size() >= s_maxIdlePerThread) {
     return;
   }
-  if (d_idle_connections.count(ip) >= s_maxIdlePerAuth) {
+  if (d_idle_connections.count(remoteAddress) >= s_maxIdlePerAuth) {
     return;
   }
 
   gettimeofday(&connection.d_last_used, nullptr);
-  d_idle_connections.emplace(ip, std::move(connection));
+  d_idle_connections.emplace(remoteAddress, std::move(connection));
 }
 
-TCPOutConnectionManager::Connection TCPOutConnectionManager::get(const ComboAddress& ip)
+TCPOutConnectionManager::Connection TCPOutConnectionManager::get(const ComboAddress& remoteAddress)
 {
-  if (d_idle_connections.count(ip) > 0) {
-    auto h = d_idle_connections.extract(ip);
-    return h.mapped();
+  if (d_idle_connections.count(remoteAddress) > 0) {
+    auto connection = d_idle_connections.extract(remoteAddress);
+    return connection.mapped();
   }
   return Connection{};
 }
index 9c2cfa4d5167d4ba5ab6ab3ca6a24fe41d9d044b..9c433be2d58caad48c7f186527f7e3ab0985d277 100644 (file)
@@ -39,7 +39,7 @@ public:
 
   struct Connection
   {
-    std::string toString() const
+    [[nodiscard]] std::string toString() const
     {
       if (d_handler) {
         return std::to_string(d_handler->getDescriptor()) + ' ' + std::to_string(d_handler.use_count());
@@ -52,17 +52,17 @@ public:
     size_t d_numqueries{0};
   };
 
-  void store(const struct timeval& now, const ComboAddress& ip, Connection&& connection);
-  Connection get(const ComboAddress& ip);
+  void store(const struct timeval& now, const ComboAddress& remoteAddress, Connection&& connection);
+  Connection get(const ComboAddress& remoteAddress);
   void cleanup(const struct timeval& now);
 
-  size_t size() const
+  [[nodiscard]] size_t size() const
   {
     return d_idle_connections.size();
   }
-  uint64_t* getSize() const
+  [[nodiscard]] uint64_t* getSize() const
   {
-    return new uint64_t(size());
+    return new uint64_t(size()); // NOLINT(cppcoreguidelines-owning-memory): it's the API
   }
 
 private: