From: Charles-Henri Bruyand Date: Thu, 16 Aug 2018 15:43:18 +0000 (+0200) Subject: dnsdist: consistent hash - also check for individual pool's policies before pre-compu... X-Git-Tag: dnsdist-1.3.3~148^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F6737%2Fhead;p=thirdparty%2Fpdns.git dnsdist: consistent hash - also check for individual pool's policies before pre-computing backend's hashes --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index d839f4043d..3b21adc532 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -2336,12 +2336,26 @@ try auto todo=setupLua(false, g_cmdLine.config); - if (g_policy.getLocal()->name == "chashed") { - vinfolog("Pre-computing hashes for consistent hash load-balancing policy"); - // pre compute hashes - auto backends = g_dstates.getLocal(); - for (auto& backend: *backends) { - backend->hash(); + auto localPools = g_pools.getCopy(); + { + bool precompute = false; + if (g_policy.getLocal()->name == "chashed") { + precompute = true; + } else { + for (const auto& entry: localPools) { + if (entry.second->policy != nullptr && entry.second->policy->name == "chashed") { + precompute = true; + break ; + } + } + } + if (precompute) { + vinfolog("Pre-computing hashes for consistent hash load-balancing policy"); + // pre compute hashes + auto backends = g_dstates.getLocal(); + for (auto& backend: *backends) { + backend->hash(); + } } } @@ -2680,7 +2694,7 @@ try for(auto& t : todo) t(); - auto localPools = g_pools.getCopy(); + localPools = g_pools.getCopy(); /* create the default pool no matter what */ createPoolIfNotExists(localPools, ""); if(g_cmdLine.remotes.size()) {