From e1c0d385a2723d65a6562feaae1a59c2834970bb Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Thu, 3 Dec 2020 09:34:08 +0100 Subject: [PATCH] rec: Handle failure to start the web server more gracefully At this point we already have several threads so calling exit() will cause problem by trying to destruct objects that are in use by other threads, so call _exit() instead. Also mention the web server in the error message so that the root cause is easier to identify. (cherry picked from commit ce715f38fcedf752220cd5056e1a3945330041fd) --- pdns/pdns_recursor.cc | 14 +++++++------- pdns/ws-recursor.cc | 7 +++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 9f63e38293..99a1952068 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -3453,7 +3453,7 @@ static bool trySendingQueryToWorker(unsigned int target, ThreadMSG* tmsg) auto& targetInfo = s_threadInfos[target]; if(!targetInfo.isWorker) { g_log< T broadcastAccFunction(const boost::function& func) { if (!isHandlerThread()) { g_log<getName() << "' multiplexer"<(new AsyncWebServer(fdm, arg()["webserver-address"], arg().asNum("webserver-port"))); + d_ws = make_unique(fdm, arg()["webserver-address"], arg().asNum("webserver-port")); + d_ws->setApiKey(arg()["api-key"]); d_ws->setPassword(arg()["webserver-password"]); d_ws->setLogLevel(arg()["webserver-loglevel"]); @@ -534,8 +535,10 @@ RecursorWebServer::RecursorWebServer(FDMultiplexer* fdm) d_ws->registerApiHandler("/api/v1/servers", &apiServer); d_ws->registerApiHandler("/api", &apiDiscovery); - for(const auto& u : g_urlmap) + for (const auto& u : g_urlmap) { d_ws->registerWebHandler("/"+u.first, serveStuff); + } + d_ws->registerWebHandler("/", serveStuff); d_ws->registerWebHandler("/metrics", prometheusMetrics); d_ws->go(); -- 2.47.2