From: Remi Gacogne Date: Tue, 26 Oct 2021 15:36:30 +0000 (+0200) Subject: dnsdist: Also allocate buffers and connect sockets for CLI backends X-Git-Tag: rec-4.6.0-beta1~28^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c543cf8f6e9b018602ed96cd0b1df26f9fd93d8;p=thirdparty%2Fpdns.git dnsdist: Also allocate buffers and connect sockets for CLI backends --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index e149fc5bca..27a2eef198 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -567,7 +567,6 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) } if (!ret->isTCPOnly() && !(client || configCheck)) { - ret->idStates.resize(g_maxOutstanding); if (!IsAnyAddress(ret->remote)) { ret->connectUDPSockets(numberOfSockets); } diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 41e8bd3745..79aaebaf8b 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -2593,9 +2593,10 @@ int main(int argc, char** argv) localPools = g_pools.getCopy(); /* create the default pool no matter what */ createPoolIfNotExists(localPools, ""); - if(g_cmdLine.remotes.size()) { - for(const auto& address : g_cmdLine.remotes) { - auto ret=std::make_shared(ComboAddress(address, 53)); + if (g_cmdLine.remotes.size()) { + for (const auto& address : g_cmdLine.remotes) { + auto ret = std::make_shared(ComboAddress(address, 53)); + ret->connectUDPSockets(1); addServerToPool(localPools, "", ret); if (ret->connected && !ret->threadStarted.test_and_set()) { ret->tid = thread(responderThread, ret); @@ -2605,7 +2606,7 @@ int main(int argc, char** argv) } g_pools.setState(localPools); - if(g_dstates.getLocal()->empty()) { + if (g_dstates.getLocal()->empty()) { errlog("No downstream servers defined: all packets will get dropped"); // you might define them later, but you need to know } diff --git a/pdns/dnsdistdist/dnsdist-backend.cc b/pdns/dnsdistdist/dnsdist-backend.cc index 7349bfffe8..2af756f8cc 100644 --- a/pdns/dnsdistdist/dnsdist-backend.cc +++ b/pdns/dnsdistdist/dnsdist-backend.cc @@ -174,6 +174,7 @@ DownstreamState::DownstreamState(const ComboAddress& remote_, const ComboAddress void DownstreamState::connectUDPSockets(size_t numberOfSockets) { + idStates.resize(g_maxOutstanding); sockets.resize(numberOfSockets); if (sockets.size() > 1) {