From: Remi Gacogne Date: Wed, 21 Aug 2024 08:50:36 +0000 (+0200) Subject: dnsdist: Handle non-existent default pool when removing a server X-Git-Tag: rec-5.2.0-alpha1~134^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7faceb1faf44dc117f8405bb8ea42185beef65a7;p=thirdparty%2Fpdns.git dnsdist: Handle non-existent default pool when removing a server --- diff --git a/pdns/dnsdistdist/dnsdist-lua.cc b/pdns/dnsdistdist/dnsdist-lua.cc index bc3d3df0ec..2233e8aa0e 100644 --- a/pdns/dnsdistdist/dnsdist-lua.cc +++ b/pdns/dnsdistdist/dnsdist-lua.cc @@ -736,8 +736,14 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) for (const string& poolName : server->d_config.pools) { removeServerFromPool(poolName, server); } - /* the server might also be in the default pool */ - removeServerFromPool("", server); + + try { + /* the server might also be in the default pool */ + removeServerFromPool("", server); + } + catch (const std::out_of_range& exp) { + /* but the default pool might not exist yet, this is fine */ + } dnsdist::configuration::updateRuntimeConfiguration([&server](dnsdist::configuration::RuntimeConfiguration& config) { config.d_backends.erase(std::remove(config.d_backends.begin(), config.d_backends.end(), server), config.d_backends.end());