From: Remi Gacogne Date: Wed, 9 Feb 2022 09:44:35 +0000 (+0100) Subject: dnsdist: Properly stop upgraded backends, remove them from pools X-Git-Tag: rec-4.7.0-alpha1~9^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69127e14797708d0010ee0018245a55a8651fdd9;p=thirdparty%2Fpdns.git dnsdist: Properly stop upgraded backends, remove them from pools --- diff --git a/pdns/dnsdistdist/dnsdist-backend.cc b/pdns/dnsdistdist/dnsdist-backend.cc index a039ee6f07..25dd110345 100644 --- a/pdns/dnsdistdist/dnsdist-backend.cc +++ b/pdns/dnsdistdist/dnsdist-backend.cc @@ -112,6 +112,9 @@ bool DownstreamState::reconnect() void DownstreamState::stop() { + if (d_stopped) { + return; + } d_stopped = true; { diff --git a/pdns/dnsdistdist/dnsdist-discovery.cc b/pdns/dnsdistdist/dnsdist-discovery.cc index 8821f4ea81..038148383b 100644 --- a/pdns/dnsdistdist/dnsdist-discovery.cc +++ b/pdns/dnsdistdist/dnsdist-discovery.cc @@ -454,7 +454,6 @@ bool ServiceDiscovery::tryToUpgradeBackend(const UpgradeableBackend& backend) else { addServerToPool(localPools, "", newServer); } - g_pools.setState(localPools); newServer->start(); @@ -468,12 +467,21 @@ bool ServiceDiscovery::tryToUpgradeBackend(const UpgradeableBackend& backend) break; } } + + for (const string& poolName : backend.d_ds->d_config.pools) { + removeServerFromPool(localPools, poolName, backend.d_ds); + } + /* the server might also be in the default pool */ + removeServerFromPool(localPools, "", backend.d_ds); } std::stable_sort(states.begin(), states.end(), [](const decltype(newServer)& a, const decltype(newServer)& b) { return a->d_config.order < b->d_config.order; }); + + g_pools.setState(localPools); g_dstates.setState(states); + backend.d_ds->stop(); return true; }