time_t now = time(nullptr);
auto purgeInterval = dnsdist::configuration::getCurrentRuntimeConfiguration().d_dynBlocksPurgeInterval;
time_t nextExpiredPurge = now + purgeInterval;
- time_t nextMetricsCollect = now + metricsCollectionInterval;
+ time_t nextMetricsCollect = now + static_cast<time_t>(metricsCollectionInterval);
time_t nextMetricsGeneration = now + metricsGenerationInterval;
while (true) {
purgeExpired(tspec);
now = time(nullptr);
- nextExpiredPurge = now + purgeInterval;
+ nextExpiredPurge = now + static_cast<time_t>(purgeInterval);
}
}
catch (const std::exception& e) {
return servers.at(candidates.at((counter++) % candidates.size()) - 1).second;
}
-const std::shared_ptr<const ServerPolicy::NumberedServerVector> getDownstreamCandidates(const std::string& poolName)
+std::shared_ptr<const ServerPolicy::NumberedServerVector> getDownstreamCandidates(const std::string& poolName)
{
std::shared_ptr<ServerPool> pool = getPool(poolName);
return pool->getServers();
{
{
const auto& pools = dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools;
- const auto it = pools.find(poolName);
- if (it != pools.end()) {
- return it->second;
+ const auto poolIt = pools.find(poolName);
+ if (poolIt != pools.end()) {
+ return poolIt->second;
}
}
std::shared_ptr<ServerPool> getPool(const std::string& poolName)
{
const auto& pools = dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools;
- auto it = pools.find(poolName);
- if (it == pools.end()) {
+ auto poolIt = pools.find(poolName);
+ if (poolIt == pools.end()) {
throw std::out_of_range("No pool named " + poolName);
}
- return it->second;
+ return poolIt->second;
}
ServerPolicy::ServerPolicy(const std::string& name_, const std::string& code): d_name(name_), d_perThreadPolicyCode(code), d_isLua(true), d_isFFI(true), d_isPerThread(true)
void addServerToPool(const string& poolName, std::shared_ptr<DownstreamState> server);
void removeServerFromPool(const string& poolName, std::shared_ptr<DownstreamState> server);
-const std::shared_ptr<const ServerPolicy::NumberedServerVector> getDownstreamCandidates(const std::string& poolName);
+std::shared_ptr<const ServerPolicy::NumberedServerVector> getDownstreamCandidates(const std::string& poolName);
std::shared_ptr<DownstreamState> firstAvailable(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq);
/* create the default pool no matter what */
createPoolIfNotExists("");
- for (auto& backend : dnsdist::configuration::getCurrentRuntimeConfiguration().d_backends) {
+ for (const auto& backend : dnsdist::configuration::getCurrentRuntimeConfiguration().d_backends) {
if (backend->connected) {
backend->start();
}
std::function<ProcessQueryResult(DNSQuestion& dq, std::shared_ptr<DownstreamState>& selectedBackend)> s_processQuery;
-ProcessQueryResult processQuery(DNSQuestion& dq, std::shared_ptr<DownstreamState>& selectedBackend)
+ProcessQueryResult processQuery(DNSQuestion& dnsQuestion, std::shared_ptr<DownstreamState>& selectedBackend)
{
if (s_processQuery) {
- return s_processQuery(dq, selectedBackend);
+ return s_processQuery(dnsQuestion, selectedBackend);
}
return ProcessQueryResult::Drop;
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture)
{
const auto tcpRecvTimeout = dnsdist::configuration::getCurrentRuntimeConfiguration().d_tcpRecvTimeout;