}
}
-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{};
}
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());
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: