using std::thread;
-static std::optional<std::vector<std::function<void(void)>>> s_launchWork{std::nullopt};
-
static boost::tribool s_noLuaSideEffect;
/* this is a best effort way to prevent logging calls with no side-effects in the output of delta()
}
if (ret->connected) {
- if (s_launchWork) {
- s_launchWork->push_back([ret]() {
- ret->start();
- });
- }
- else {
+ if (!dnsdist::configuration::isConfigurationDone()) {
ret->start();
}
}
});
}
-vector<std::function<void(void)>> setupLua(LuaContext& luaCtx, bool client, bool configCheck, const std::string& config)
+void setupLua(LuaContext& luaCtx, bool client, bool configCheck, const std::string& config)
{
- // this needs to exist only during the parsing of the configuration
- // and cannot be captured by lambdas
- s_launchWork = std::vector<std::function<void(void)>>();
-
setupLuaActions(luaCtx);
setupLuaConfig(luaCtx, client, configCheck);
setupLuaBindings(luaCtx, client, configCheck);
}
luaCtx.executeCode(ifs);
-
- auto ret = std::move(*s_launchWork);
- s_launchWork = std::nullopt;
-
- return ret;
}
void parseRuleParams(boost::optional<luaruleparams_t>& params, boost::uuids::uuid& uuid, std::string& name, uint64_t& creationOrder);
void checkParameterBound(const std::string& parameter, uint64_t value, size_t max = std::numeric_limits<uint16_t>::max());
-std::vector<std::function<void(void)>> setupLua(LuaContext& luaCtx, bool client, bool configCheck, const std::string& config);
+void setupLua(LuaContext& luaCtx, bool client, bool configCheck, const std::string& config);
void setupLuaActions(LuaContext& luaCtx);
void setupLuaBindings(LuaContext& luaCtx, bool client, bool configCheck);
void setupLuaBindingsDNSCrypt(LuaContext& luaCtx, bool client);
dnsdist::g_asyncHolder = std::make_unique<dnsdist::AsynchronousHolder>();
- auto todo = setupLua(*(g_lua.lock()), false, false, cmdLine.config);
+ setupLua(*(g_lua.lock()), false, false, cmdLine.config);
setupPools();
webServerThread.detach();
}
- for (auto& todoItem : todo) {
- todoItem();
- }
-
/* create the default pool no matter what */
createPoolIfNotExists("");
+
+ for (auto& backend : dnsdist::configuration::getCurrentRuntimeConfiguration().d_backends) {
+ if (backend->connected) {
+ backend->start();
+ }
+ }
+
if (!cmdLine.remotes.empty()) {
for (const auto& address : cmdLine.remotes) {
DownstreamState::Config config;