From: Remi Gacogne Date: Fri, 18 Jul 2025 08:15:36 +0000 (+0200) Subject: dnsdist: Server pools are no longer ref counted X-Git-Tag: rec-5.4.0-alpha1~224^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0aa18177bb5b11070d4eb7e8b83cd8c6212242c9;p=thirdparty%2Fpdns.git dnsdist: Server pools are no longer ref counted Since the refactoring of the runtime configuration, the content of a Server Pool is now in effect immutable, we have to create a new copy and update it, so we no longer have to lock and reference count Server Pools and their content. Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsdistdist/dnsdist-backend.cc b/pdns/dnsdistdist/dnsdist-backend.cc index fa44589457..ad8d7fde31 100644 --- a/pdns/dnsdistdist/dnsdist-backend.cc +++ b/pdns/dnsdistdist/dnsdist-backend.cc @@ -1015,16 +1015,10 @@ unsigned int DownstreamState::getQPSLimit() const return d_qpsLimiter ? d_qpsLimiter->getRate() : 0U; } -size_t ServerPool::countServers(bool upOnly) +size_t ServerPool::countServers(bool upOnly) const { - std::shared_ptr servers = nullptr; - { - auto lock = d_servers.read_lock(); - servers = *lock; - } - size_t count = 0; - for (const auto& server : *servers) { + for (const auto& server : d_servers) { if (!upOnly || std::get<1>(server)->isUp() ) { count++; } @@ -1033,51 +1027,36 @@ size_t ServerPool::countServers(bool upOnly) return count; } -size_t ServerPool::poolLoad() +size_t ServerPool::poolLoad() const { - std::shared_ptr servers = nullptr; - { - auto lock = d_servers.read_lock(); - servers = *lock; - } - size_t load = 0; - for (const auto& server : *servers) { + for (const auto& server : d_servers) { size_t serverOutstanding = std::get<1>(server)->outstanding.load(); load += serverOutstanding; } return load; } -const std::shared_ptr ServerPool::getServers() +const ServerPolicy::NumberedServerVector& ServerPool::getServers() const { - std::shared_ptr result; - { - result = *(d_servers.read_lock()); - } - return result; + return d_servers; } -void ServerPool::addServer(shared_ptr& server) +void ServerPool::addServer(std::shared_ptr& server) { - auto servers = d_servers.write_lock(); - /* we can't update the content of the shared pointer directly even when holding the lock, - as other threads might hold a copy. We can however update the pointer as long as we hold the lock. */ - unsigned int count = static_cast((*servers)->size()); - auto newServers = ServerPolicy::NumberedServerVector(*(*servers)); - newServers.emplace_back(++count, server); + unsigned int count = static_cast(d_servers.size()); + d_servers.emplace_back(++count, server); /* we need to reorder based on the server 'order' */ - std::stable_sort(newServers.begin(), newServers.end(), [](const std::pair >& a, const std::pair >& b) { + std::stable_sort(d_servers.begin(), d_servers.end(), [](const std::pair >& a, const std::pair >& b) { return a.second->d_config.order < b.second->d_config.order; }); /* and now we need to renumber for Lua (custom policies) */ size_t idx = 1; - for (auto& serv : newServers) { + for (auto& serv : d_servers) { serv.first = idx++; } - *servers = std::make_shared(std::move(newServers)); - if ((*servers)->size() == 1) { + if (d_servers.size() == 1) { d_tcpOnly = server->isTCPOnly(); } else if (!server->isTCPOnly()) { @@ -1087,14 +1066,10 @@ void ServerPool::addServer(shared_ptr& server) void ServerPool::removeServer(shared_ptr& server) { - auto servers = d_servers.write_lock(); - /* we can't update the content of the shared pointer directly even when holding the lock, - as other threads might hold a copy. We can however update the pointer as long as we hold the lock. */ - auto newServers = std::make_shared(*(*servers)); size_t idx = 1; bool found = false; bool tcpOnly = true; - for (auto it = newServers->begin(); it != newServers->end();) { + for (auto it = d_servers.begin(); it != d_servers.end();) { if (found) { tcpOnly = tcpOnly && it->second->isTCPOnly(); /* we need to renumber the servers placed @@ -1103,7 +1078,7 @@ void ServerPool::removeServer(shared_ptr& server) it++; } else if (it->second == server) { - it = newServers->erase(it); + it = d_servers.erase(it); found = true; } else { tcpOnly = tcpOnly && it->second->isTCPOnly(); @@ -1112,7 +1087,6 @@ void ServerPool::removeServer(shared_ptr& server) } } d_tcpOnly = tcpOnly; - *servers = std::move(newServers); } namespace dnsdist::backend diff --git a/pdns/dnsdistdist/dnsdist-carbon.cc b/pdns/dnsdistdist/dnsdist-carbon.cc index 98f254f143..82ae493504 100644 --- a/pdns/dnsdistdist/dnsdist-carbon.cc +++ b/pdns/dnsdistdist/dnsdist-carbon.cc @@ -194,13 +194,13 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint) base += ".pools."; base += poolName; base += "."; - const std::shared_ptr pool = entry.second; + const ServerPool& pool = entry.second; str << base << "servers" - << " " << pool->countServers(false) << " " << now << "\r\n"; + << " " << pool.countServers(false) << " " << now << "\r\n"; str << base << "servers-up" - << " " << pool->countServers(true) << " " << now << "\r\n"; - if (pool->packetCache != nullptr) { - const auto& cache = pool->packetCache; + << " " << pool.countServers(true) << " " << now << "\r\n"; + if (pool.packetCache != nullptr) { + const auto& cache = pool.packetCache; str << base << "cache-size" << " " << cache->getMaxEntries() << " " << now << "\r\n"; str << base << "cache-entries" diff --git a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc index e2b36bc2c8..013854e430 100644 --- a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc +++ b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc @@ -1215,13 +1215,19 @@ bool loadConfigurationFromFile(const std::string& fileName, [[maybe_unused]] boo } for (const auto& pool : globalConfig.pools) { - std::shared_ptr poolObj = createPoolIfNotExists(std::string(pool.name)); - if (!pool.packet_cache.empty()) { - poolObj->packetCache = getRegisteredTypeByName(pool.packet_cache); - } - if (!pool.policy.empty()) { - poolObj->policy = getRegisteredTypeByName(pool.policy); - } + dnsdist::configuration::updateRuntimeConfiguration([&pool](dnsdist::configuration::RuntimeConfiguration& config) { + auto [poolIt, inserted] = config.d_pools.emplace(std::string(pool.name), ServerPool()); + if (inserted) { + vinfolog("Creating pool %s", pool.name); + } + + if (!pool.packet_cache.empty()) { + poolIt->second.packetCache = getRegisteredTypeByName(pool.packet_cache); + } + if (!pool.policy.empty()) { + poolIt->second.policy = getRegisteredTypeByName(pool.policy); + } + }); } loadRulesConfiguration(globalConfig); diff --git a/pdns/dnsdistdist/dnsdist-configuration.hh b/pdns/dnsdistdist/dnsdist-configuration.hh index a60a506867..605d735278 100644 --- a/pdns/dnsdistdist/dnsdist-configuration.hh +++ b/pdns/dnsdistdist/dnsdist-configuration.hh @@ -33,6 +33,7 @@ #include "dnsdist-carbon.hh" #include "dnsdist-query-count.hh" #include "dnsdist-rule-chains.hh" +#include "dnsdist-server-pool.hh" #include "iputils.hh" class ServerPolicy; @@ -118,7 +119,7 @@ struct RuntimeConfiguration #ifndef DISABLE_CARBON std::vector d_carbonEndpoints; #endif /* DISABLE_CARBON */ - std::unordered_map> d_pools; + std::unordered_map d_pools; std::shared_ptr d_webPassword; std::shared_ptr d_webAPIKey; std::optional> d_webCustomHeaders; diff --git a/pdns/dnsdistdist/dnsdist-lbpolicies.cc b/pdns/dnsdistdist/dnsdist-lbpolicies.cc index c8749196fe..58075c41a5 100644 --- a/pdns/dnsdistdist/dnsdist-lbpolicies.cc +++ b/pdns/dnsdistdist/dnsdist-lbpolicies.cc @@ -289,13 +289,12 @@ shared_ptr orderedWrandUntag(const ServerPolicy::NumberedServer return wrandom(candidates, dnsq); } -std::shared_ptr getDownstreamCandidates(const std::string& poolName) +const ServerPolicy::NumberedServerVector& getDownstreamCandidates(const std::string& poolName) { - std::shared_ptr pool = getPool(poolName); - return pool->getServers(); + return getPool(poolName).getServers(); } -std::shared_ptr createPoolIfNotExists(const string& poolName) +const ServerPool& createPoolIfNotExists(const string& poolName) { { const auto& pools = dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools; @@ -309,40 +308,47 @@ std::shared_ptr createPoolIfNotExists(const string& poolName) vinfolog("Creating pool %s", poolName); } - auto pool = std::make_shared(); - dnsdist::configuration::updateRuntimeConfiguration([&poolName,&pool](dnsdist::configuration::RuntimeConfiguration& config) { - config.d_pools.emplace(poolName, pool); + dnsdist::configuration::updateRuntimeConfiguration([&poolName](dnsdist::configuration::RuntimeConfiguration& config) { + config.d_pools.emplace(poolName, ServerPool()); }); - return pool; + { + const auto& pools = dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools; + const auto poolIt = pools.find(poolName); + return poolIt->second; + } } void setPoolPolicy(const string& poolName, std::shared_ptr policy) { - std::shared_ptr pool = createPoolIfNotExists(poolName); if (!poolName.empty()) { vinfolog("Setting pool %s server selection policy to %s", poolName, policy->getName()); } else { vinfolog("Setting default pool server selection policy to %s", policy->getName()); } - pool->policy = std::move(policy); + + dnsdist::configuration::updateRuntimeConfiguration([&poolName, &policy](dnsdist::configuration::RuntimeConfiguration& config) { + auto [poolIt, inserted] = config.d_pools.emplace(poolName, ServerPool()); + poolIt->second.policy = std::move(policy); + }); } void addServerToPool(const string& poolName, std::shared_ptr server) { - std::shared_ptr pool = createPoolIfNotExists(poolName); if (!poolName.empty()) { vinfolog("Adding server to pool %s", poolName); } else { vinfolog("Adding server to default pool"); } - pool->addServer(server); + + dnsdist::configuration::updateRuntimeConfiguration([&poolName, &server](dnsdist::configuration::RuntimeConfiguration& config) { + auto [poolIt, inserted] = config.d_pools.emplace(poolName, ServerPool()); + poolIt->second.addServer(server); + }); } void removeServerFromPool(const string& poolName, std::shared_ptr server) { - std::shared_ptr pool = getPool(poolName); - if (!poolName.empty()) { vinfolog("Removing server from pool %s", poolName); } @@ -350,10 +356,13 @@ void removeServerFromPool(const string& poolName, std::shared_ptrremoveServer(server); + dnsdist::configuration::updateRuntimeConfiguration([&poolName, &server](dnsdist::configuration::RuntimeConfiguration& config) { + auto [poolIt, inserted] = config.d_pools.emplace(poolName, ServerPool()); + poolIt->second.removeServer(server); + }); } -std::shared_ptr getPool(const std::string& poolName) +const ServerPool& getPool(const std::string& poolName) { const auto& pools = dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools; auto poolIt = pools.find(poolName); diff --git a/pdns/dnsdistdist/dnsdist-lbpolicies.hh b/pdns/dnsdistdist/dnsdist-lbpolicies.hh index 291fa754ef..a6ea89f706 100644 --- a/pdns/dnsdistdist/dnsdist-lbpolicies.hh +++ b/pdns/dnsdistdist/dnsdist-lbpolicies.hh @@ -92,13 +92,13 @@ public: struct ServerPool; using pools_t = std::map>; -std::shared_ptr getPool(const std::string& poolName); -std::shared_ptr createPoolIfNotExists(const string& poolName); +const ServerPool& getPool(const std::string& poolName); +const ServerPool& createPoolIfNotExists(const string& poolName); void setPoolPolicy(const string& poolName, std::shared_ptr policy); void addServerToPool(const string& poolName, std::shared_ptr server); void removeServerFromPool(const string& poolName, std::shared_ptr server); -std::shared_ptr getDownstreamCandidates(const std::string& poolName); +const ServerPolicy::NumberedServerVector& getDownstreamCandidates(const std::string& poolName); std::shared_ptr firstAvailable(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq); diff --git a/pdns/dnsdistdist/dnsdist-lua-bindings.cc b/pdns/dnsdistdist/dnsdist-lua-bindings.cc index 033ffe4e4a..ca14401186 100644 --- a/pdns/dnsdistdist/dnsdist-lua-bindings.cc +++ b/pdns/dnsdistdist/dnsdist-lua-bindings.cc @@ -94,19 +94,68 @@ void setupLuaBindings(LuaContext& luaCtx, bool client, bool configCheck) #endif /* DISABLE_POLICIES_BINDINGS */ /* ServerPool */ - luaCtx.registerFunction::*)(std::shared_ptr)>("setCache", [](const std::shared_ptr& pool, std::shared_ptr cache) { + luaCtx.registerFunction::*)(std::shared_ptr)>("setCache", [](const std::shared_ptr& pool, std::shared_ptr cache) { if (pool) { - pool->packetCache = std::move(cache); + dnsdist::configuration::updateRuntimeConfiguration([&pool, &cache](dnsdist::configuration::RuntimeConfiguration& config) { + auto poolIt = config.d_pools.find(pool->poolName); + if (poolIt == config.d_pools.end()) { + /* this might happen if the Server Pool has been removed in the meantime, let's gracefully ignore it */ + return; + } + poolIt->second.packetCache = std::move(cache); + }); + } + }); + luaCtx.registerFunction (std::shared_ptr::*)() const>("getCache", [](const std::shared_ptr& pool) { + std::shared_ptr cache; + if (pool) { + dnsdist::configuration::updateRuntimeConfiguration([&pool, &cache](dnsdist::configuration::RuntimeConfiguration& config) { + auto poolIt = config.d_pools.find(pool->poolName); + /* this might happen if the Server Pool has been removed in the meantime, let's gracefully ignore it */ + if (poolIt != config.d_pools.end()) { + cache = poolIt->second.packetCache; + } + }); + } + return cache; + }); + luaCtx.registerFunction::*)()>("unsetCache", [](const std::shared_ptr& pool) { + if (pool) { + dnsdist::configuration::updateRuntimeConfiguration([&pool](dnsdist::configuration::RuntimeConfiguration& config) { + auto poolIt = config.d_pools.find(pool->poolName); + if (poolIt == config.d_pools.end()) { + /* this might happen if the Server Pool has been removed in the meantime, let's gracefully ignore it */ + return; + } + poolIt->second.packetCache.reset(); + }); } }); - luaCtx.registerFunction("getCache", &ServerPool::getCache); - luaCtx.registerFunction::*)()>("unsetCache", [](const std::shared_ptr& pool) { + luaCtx.registerFunction::*)() const>("getECS", [](const std::shared_ptr& pool) { + bool ecs = false; if (pool) { - pool->packetCache = nullptr; + dnsdist::configuration::updateRuntimeConfiguration([&pool, &ecs](dnsdist::configuration::RuntimeConfiguration& config) { + auto poolIt = config.d_pools.find(pool->poolName); + /* this might happen if the Server Pool has been removed in the meantime, let's gracefully ignore it */ + if (poolIt != config.d_pools.end()) { + ecs = poolIt->second.getECS(); + } + }); + } + return ecs; + }); + luaCtx.registerFunction::*)(bool ecs)>("setECS", [](std::shared_ptr& pool, bool ecs) { + if (pool) { + dnsdist::configuration::updateRuntimeConfiguration([&pool, ecs](dnsdist::configuration::RuntimeConfiguration& config) { + auto poolIt = config.d_pools.find(pool->poolName); + if (poolIt == config.d_pools.end()) { + /* this might happen if the Server Pool has been removed in the meantime, let's gracefully ignore it */ + return; + } + poolIt->second.setECS(ecs); + }); } }); - luaCtx.registerFunction("getECS", &ServerPool::getECS); - luaCtx.registerFunction("setECS", &ServerPool::setECS); #ifndef DISABLE_DOWNSTREAM_BINDINGS /* DownstreamState */ diff --git a/pdns/dnsdistdist/dnsdist-lua-ffi.cc b/pdns/dnsdistdist/dnsdist-lua-ffi.cc index 9492361c34..dfcf23001d 100644 --- a/pdns/dnsdistdist/dnsdist-lua-ffi.cc +++ b/pdns/dnsdistdist/dnsdist-lua-ffi.cc @@ -1260,12 +1260,12 @@ size_t dnsdist_ffi_packetcache_get_domain_list_by_addr(const char* poolName, con return 0; } - auto pool = poolIt->second; - if (!pool->packetCache) { + const auto& pool = poolIt->second; + if (!pool.packetCache) { return 0; } - auto domains = pool->packetCache->getDomainsContainingRecords(ca); + auto domains = pool.packetCache->getDomainsContainingRecords(ca); if (domains.size() == 0) { return 0; } @@ -1309,12 +1309,12 @@ size_t dnsdist_ffi_packetcache_get_address_list_by_domain(const char* poolName, return 0; } - auto pool = poolIt->second; - if (!pool->packetCache) { + const auto& pool = poolIt->second; + if (!pool.packetCache) { return 0; } - auto addresses = pool->packetCache->getRecordsForDomain(name); + auto addresses = pool.packetCache->getRecordsForDomain(name); if (addresses.size() == 0) { return 0; } diff --git a/pdns/dnsdistdist/dnsdist-lua.cc b/pdns/dnsdistdist/dnsdist-lua.cc index 151f935647..f84fc4af61 100644 --- a/pdns/dnsdistdist/dnsdist-lua.cc +++ b/pdns/dnsdistdist/dnsdist-lua.cc @@ -1008,9 +1008,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) }); luaCtx.writeFunction("getPoolServers", [](const string& pool) { - // coverity[auto_causes_copy] - const auto poolServers = getDownstreamCandidates(pool); - return *poolServers; + return getDownstreamCandidates(pool); }); luaCtx.writeFunction("getServer", [client](boost::variant identifier) -> boost::optional> { @@ -1636,16 +1634,16 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) const auto pools = dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools; for (const auto& entry : pools) { const string& name = entry.first; - const std::shared_ptr pool = entry.second; - string cache = pool->packetCache != nullptr ? pool->packetCache->toString() : ""; + const auto& pool = entry.second; + string cache = pool.packetCache != nullptr ? pool.packetCache->toString() : ""; string policy = defaultPolicyName; - if (pool->policy != nullptr) { - policy = pool->policy->getName(); + if (pool.policy != nullptr) { + policy = pool.policy->getName(); } string servers; - const auto poolServers = pool->getServers(); - for (const auto& server : *poolServers) { + const auto& poolServers = pool.getServers(); + for (const auto& server : poolServers) { if (!servers.empty()) { servers += ", "; } @@ -1680,10 +1678,19 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) luaCtx.writeFunction("getPool", [client](const string& poolName) { if (client) { - return std::make_shared(); + return std::make_shared(poolName); } - std::shared_ptr pool = createPoolIfNotExists(poolName); - return pool; + bool created = false; + dnsdist::configuration::updateRuntimeConfiguration([&poolName, &created](dnsdist::configuration::RuntimeConfiguration& config) { + auto [poolIt, inserted] = config.d_pools.emplace(poolName, ServerPool()); + created = inserted; + }); + + if (created) { + vinfolog("Creating pool %s", poolName); + } + + return std::make_shared(poolName); }); luaCtx.writeFunction("setVerboseLogDestination", [](const std::string& dest) { @@ -2069,11 +2076,11 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) luaCtx.writeFunction("showPoolServerPolicy", [](const std::string& pool) { setLuaSideEffect(); auto poolObj = getPool(pool); - if (poolObj->policy == nullptr) { + if (poolObj.policy == nullptr) { g_outputBuffer = dnsdist::configuration::getCurrentRuntimeConfiguration().d_lbPolicy->getName() + "\n"; } else { - g_outputBuffer = poolObj->policy->getName() + "\n"; + g_outputBuffer = poolObj.policy->getName() + "\n"; } }); #endif /* DISABLE_POLICIES_BINDINGS */ diff --git a/pdns/dnsdistdist/dnsdist-lua.hh b/pdns/dnsdistdist/dnsdist-lua.hh index 73f81329c5..980078c533 100644 --- a/pdns/dnsdistdist/dnsdist-lua.hh +++ b/pdns/dnsdistdist/dnsdist-lua.hh @@ -85,6 +85,16 @@ std::optional getFunctionFromLuaCode(const std::string& code, cons return std::nullopt; } + +struct LuaServerPoolObject +{ + LuaServerPoolObject(std::string name) : + poolName(std::move(name)) + { + } + + std::string poolName; +}; } namespace dnsdist::configuration::lua diff --git a/pdns/dnsdistdist/dnsdist-rules-factory.hh b/pdns/dnsdistdist/dnsdist-rules-factory.hh index 48f2100014..36bc0519f4 100644 --- a/pdns/dnsdistdist/dnsdist-rules-factory.hh +++ b/pdns/dnsdistdist/dnsdist-rules-factory.hh @@ -1178,7 +1178,7 @@ public: bool matches(const DNSQuestion* dnsQuestion) const override { (void)dnsQuestion; - return (getPool(d_poolname)->countServers(true) > 0); + return (getPool(d_poolname).countServers(true) > 0); } string toString() const override @@ -1201,7 +1201,7 @@ public: bool matches(const DNSQuestion* dnsQuestion) const override { (void)dnsQuestion; - return (getPool(d_poolname)->poolLoad()) > d_limit; + return (getPool(d_poolname).poolLoad()) > d_limit; } string toString() const override diff --git a/pdns/dnsdistdist/dnsdist-server-pool.hh b/pdns/dnsdistdist/dnsdist-server-pool.hh new file mode 100644 index 0000000000..84e48f171d --- /dev/null +++ b/pdns/dnsdistdist/dnsdist-server-pool.hh @@ -0,0 +1,63 @@ +/* + * This file is part of PowerDNS or dnsdist. + * Copyright -- PowerDNS.COM B.V. and its contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * In addition, for the avoidance of any doubt, permission is granted to + * link this program with OpenSSL and to (re)distribute the binaries + * produced as the result of such linking. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#pragma once +#include + +#include "dnsdist-lbpolicies.hh" + +class DNSDistPacketCache; + +struct ServerPool +{ + const std::shared_ptr getCache() const + { + return packetCache; + } + + bool getECS() const + { + return d_useECS; + } + + void setECS(bool useECS) + { + d_useECS = useECS; + } + + size_t poolLoad() const; + size_t countServers(bool upOnly) const; + const ServerPolicy::NumberedServerVector& getServers() const; + void addServer(std::shared_ptr& server); + void removeServer(std::shared_ptr& server); + bool isTCPOnly() const + { + return d_tcpOnly; + } + + std::shared_ptr packetCache{nullptr}; + std::shared_ptr policy{nullptr}; + +private: + ServerPolicy::NumberedServerVector d_servers; + bool d_useECS{false}; + bool d_tcpOnly{false}; +}; diff --git a/pdns/dnsdistdist/dnsdist-web.cc b/pdns/dnsdistdist/dnsdist-web.cc index d7a91e60b4..3103742a39 100644 --- a/pdns/dnsdistdist/dnsdist-web.cc +++ b/pdns/dnsdistdist/dnsdist-web.cc @@ -867,12 +867,12 @@ static void handlePrometheus(const YaHTTP::Request& req, YaHTTP::Response& resp) poolName = "_default_"; } const string label = "{pool=\"" + poolName + "\"}"; - const std::shared_ptr pool = entry.second; - output << "dnsdist_pool_servers" << label << " " << pool->countServers(false) << "\n"; - output << "dnsdist_pool_active_servers" << label << " " << pool->countServers(true) << "\n"; + const auto& pool = entry.second; + output << "dnsdist_pool_servers" << label << " " << pool.countServers(false) << "\n"; + output << "dnsdist_pool_active_servers" << label << " " << pool.countServers(true) << "\n"; - if (pool->packetCache != nullptr) { - const auto& cache = pool->packetCache; + if (pool.packetCache != nullptr) { + const auto& cache = pool.packetCache; output << cachebase << "cache_size" <