From: Otto Moerbeek Date: Tue, 18 Feb 2025 09:53:44 +0000 (+0100) Subject: Tidy rec-tcpout.?? X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b4528512074f114ba2c28a5f2f4dfbe422cd9651;p=thirdparty%2Fpdns.git Tidy rec-tcpout.?? --- diff --git a/pdns/recursordist/rec-tcpout.cc b/pdns/recursordist/rec-tcpout.cc index 8b65110e0f..4693701835 100644 --- a/pdns/recursordist/rec-tcpout.cc +++ b/pdns/recursordist/rec-tcpout.cc @@ -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{}; } diff --git a/pdns/recursordist/rec-tcpout.hh b/pdns/recursordist/rec-tcpout.hh index 9c2cfa4d51..9c433be2d5 100644 --- a/pdns/recursordist/rec-tcpout.hh +++ b/pdns/recursordist/rec-tcpout.hh @@ -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: