From: Otto Date: Mon, 13 Sep 2021 08:16:55 +0000 (+0200) Subject: Process comments from review: X-Git-Tag: rec-4.6.0-alpha1~2^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a8635021f774f7b494fa18e485daadf529387e4;p=thirdparty%2Fpdns.git Process comments from review: - Pass current time as arg where appropiate; - Use rvalue ref for Connection in store(). --- diff --git a/pdns/lwres.cc b/pdns/lwres.cc index 1dc559921d..f0cee4fe21 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -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; diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 5fae14c11f..9b0af4ef0c 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -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()) { diff --git a/pdns/recursordist/rec-tcpout.cc b/pdns/recursordist/rec-tcpout.cc index 97ccb16853..f9e7a6942f 100644 --- a/pdns/recursordist/rec-tcpout.cc +++ b/pdns/recursordist/rec-tcpout.cc @@ -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) { diff --git a/pdns/recursordist/rec-tcpout.hh b/pdns/recursordist/rec-tcpout.hh index 70620800f2..4caa42713d 100644 --- a/pdns/recursordist/rec-tcpout.hh +++ b/pdns/recursordist/rec-tcpout.hh @@ -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 {