From: Pieter Lexis Date: Thu, 27 Sep 2018 07:10:02 +0000 (+0200) Subject: pdns-recursor: Name all threads X-Git-Tag: dnsdist-1.3.3~68^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c390b2da2405639e47c14fc8be7a5f11cb219260;p=thirdparty%2Fpdns.git pdns-recursor: Name all threads --- diff --git a/pdns/nod.cc b/pdns/nod.cc index 287bd45f57..ef3c8a3d67 100644 --- a/pdns/nod.cc +++ b/pdns/nod.cc @@ -99,6 +99,11 @@ bool NODDB::init(bool ignore_pid) { void NODDB::housekeepingThread() { + string threadName = "pdns-r/NOD-hk"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + g_log< #endif #include "ws-recursor.hh" +#include #include #include "recpacketcache.hh" #include "utility.hh" @@ -3095,7 +3096,7 @@ static void checkOrFixFDS() } } -static void* recursorThread(unsigned int tid); +static void* recursorThread(unsigned int tid, const string& threadName); static void* pleaseSupplantACLs(std::shared_ptr ng) { @@ -3680,14 +3681,14 @@ static int serviceMain(int argc, char*argv[]) /* This thread handles the web server, carbon, statistics and the control channel */ auto& handlerInfos = s_threadInfos.at(0); handlerInfos.isHandler = true; - handlerInfos.thread = std::thread(recursorThread, 0); + handlerInfos.thread = std::thread(recursorThread, 0, "main"); setCPUMap(cpusMap, currentThreadId, pthread_self()); auto& infos = s_threadInfos.at(currentThreadId); infos.isListener = true; infos.isWorker = true; - recursorThread(currentThreadId++); + recursorThread(currentThreadId++, "worker"); } else { @@ -3696,7 +3697,7 @@ static int serviceMain(int argc, char*argv[]) for(unsigned int n=0; n < g_numDistributorThreads; ++n) { auto& infos = s_threadInfos.at(currentThreadId); infos.isListener = true; - infos.thread = std::thread(recursorThread, currentThreadId++); + infos.thread = std::thread(recursorThread, currentThreadId++, "distr"); setCPUMap(cpusMap, currentThreadId, infos.thread.native_handle()); } @@ -3708,7 +3709,7 @@ static int serviceMain(int argc, char*argv[]) auto& infos = s_threadInfos.at(currentThreadId); infos.isListener = g_weDistributeQueries ? false : true; infos.isWorker = true; - infos.thread = std::thread(recursorThread, currentThreadId++); + infos.thread = std::thread(recursorThread, currentThreadId++, "worker"); setCPUMap(cpusMap, currentThreadId, infos.thread.native_handle()); } @@ -3720,18 +3721,26 @@ static int serviceMain(int argc, char*argv[]) /* This thread handles the web server, carbon, statistics and the control channel */ auto& infos = s_threadInfos.at(0); infos.isHandler = true; - infos.thread = std::thread(recursorThread, 0); + infos.thread = std::thread(recursorThread, 0, "web+stat"); s_threadInfos.at(0).thread.join(); } return 0; } -static void* recursorThread(unsigned int n) +static void* recursorThread(unsigned int n, const string& threadName) try { t_id=n; auto& threadInfo = s_threadInfos.at(t_id); + + static string threadPrefix = "pdns-r/"; + + auto retval = pthread_setname_np(pthread_self(), const_cast((threadPrefix + threadName).c_str())); + if (retval != 0) { + g_log< +#include #include "remote_logger.hh" #include "config.h" #ifdef PDNS_CONFIG_ARGS @@ -41,6 +42,11 @@ void RemoteLogger::busyReconnectLoop() void RemoteLogger::worker() { + string threadName = "pdns-r/remLog"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + g_log< #include "dnsparser.hh" #include "dnsrecords.hh" #include "ixfr.hh" @@ -339,6 +340,12 @@ static bool dumpZoneToDisk(const DNSName& zoneName, const std::shared_ptr masters, boost::optional defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, std::shared_ptr sr, std::string dumpZoneFileName, uint64_t configGeneration) { + string threadName = "pdns-r/RPZIXFR"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + g_log<(threadName.c_str())); + if (retval != 0) { + g_log< +#include #include #include "logger.hh" #include @@ -195,6 +196,11 @@ void WebServer::registerWebHandler(const string& url, HandlerFunction handler) { } static void *WebServerConnectionThreadStart(const WebServer* webServer, std::shared_ptr client) { + string threadName = "pdns-r/webhndlr"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + g_log<serveConnection(client); return nullptr; }