]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Process comments from review:
authorOtto <otto.moerbeek@open-xchange.com>
Mon, 13 Sep 2021 08:16:55 +0000 (10:16 +0200)
committerOtto <otto.moerbeek@open-xchange.com>
Fri, 24 Sep 2021 07:59:44 +0000 (09:59 +0200)
- Pass current time as arg where appropiate;
- Use rvalue ref for Connection in store().

pdns/lwres.cc
pdns/pdns_recursor.cc
pdns/recursordist/rec-tcpout.cc
pdns/recursordist/rec-tcpout.hh

index 1dc559921dea976c0b3a26fb6968496a5cc70cf1..f0cee4fe2174c6759264aff86afed85938bd7b23 100644 (file)
@@ -558,7 +558,7 @@ LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int
       ret = asyncresolve(ip, domain, type,doTCP, sendRDQuery, EDNS0Level, now, srcmask, context, outgoingLoggers, fstrmLoggers, exportTypes, lwr, chained, connection);
     } 
     if (connection.d_handler && lwr->d_validpacket) {
-      t_tcp_manager.store(ip, connection);
+      t_tcp_manager.store(*now, ip, std::move(connection));
     }
   }
   return ret;
index 5fae14c11f567ee18044110008ef12c2619ce32b..9b0af4ef0c2bb9d8b2ea4d1c1ab6ff5c91f07b4e 100644 (file)
@@ -3735,7 +3735,7 @@ static void houseKeeping(void *)
       SyncRes::pruneThrottledServers();
       SyncRes::pruneNonResolving(now.tv_sec - SyncRes::s_nonresolvingnsthrottletime);
       Utility::gettimeofday(&last_prune, nullptr);
-      t_tcp_manager.cleanup();
+      t_tcp_manager.cleanup(now);
     }
 
     if(isHandlerThread()) {
index 97ccb16853d08efc2ca724ad88496c7230ef1a06..f9e7a6942f5801681f62eb0e04e6274d8e50bd5c 100644 (file)
@@ -33,14 +33,12 @@ size_t TCPOutConnectionManager::maxQueries;
 size_t TCPOutConnectionManager::maxIdlePerAuth;
 size_t TCPOutConnectionManager::maxIdlePerThread;
 
-void TCPOutConnectionManager::cleanup()
+void TCPOutConnectionManager::cleanup(const struct timeval& now)
 {
   if (maxIdleTime.tv_sec == 0 && maxIdleTime.tv_usec == 0) {
     // no maximum idle time
     return;
   }
-  struct timeval now;
-  gettimeofday(&now, nullptr);
 
   for (auto it = d_idle_connections.begin(); it != d_idle_connections.end();) {
     timeval idle = now - it->second.d_last_used;
@@ -53,10 +51,10 @@ void TCPOutConnectionManager::cleanup()
   }
 }
 
-void TCPOutConnectionManager::store(const ComboAddress& ip, Connection& connection)
+void TCPOutConnectionManager::store(const struct timeval& now, const ComboAddress& ip, Connection&& connection)
 {
   if (d_idle_connections.size() >= maxIdlePerThread || d_idle_connections.count(ip) >= maxIdlePerAuth) {
-    cleanup();
+    cleanup(now);
   }
 
   if (d_idle_connections.size() >= maxIdlePerThread) {
index 70620800f2d789b4d206f274868ba6174319aca3..4caa42713d17ca8b34704828067ea2dd6e24c842 100644 (file)
@@ -52,9 +52,9 @@ public:
     size_t d_numqueries{0};
   };
 
-  void store(const ComboAddress& ip, Connection& connection);
+  void store(const struct timeval &now, const ComboAddress& ip, Connection&& connection);
   Connection get(const ComboAddress& ip);
-  void cleanup();
+  void cleanup(const struct timeval& now);
 
   size_t size() const
   {