From: Remi Gacogne Date: Thu, 3 Dec 2020 08:34:08 +0000 (+0100) Subject: rec: Handle failure to start the web server more gracefully X-Git-Tag: rec-4.4.3~8^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F10199%2Fhead;p=thirdparty%2Fpdns.git 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) --- 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();