From: Otto Moerbeek Date: Mon, 31 Jan 2022 09:46:36 +0000 (+0100) Subject: Make ping reply with thread name X-Git-Tag: auth-4.7.0-alpha1~19^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aee3ab9f25670fca264cedfefcc5b3d87d46f964;p=thirdparty%2Fpdns.git Make ping reply with thread name --- diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 9523d738b9..b03c314608 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -1669,7 +1669,7 @@ static string doGenericTopQueries(pleasequeryfunc_t func, boost::function>& cpusMap, unsi static void recursorThread(); -void RecThreadInfo::start(unsigned int id, const string& name, const std::map>& cpusMap) +void RecThreadInfo::start(unsigned int id, const string& tname, const std::map>& cpusMap) { - thread = std::thread([id, name] { + name = tname; + thread = std::thread([id, tname] { t_id = id; const string threadPrefix = "rec/"; - setThreadName(threadPrefix + name); + setThreadName(threadPrefix + tname); recursorThread(); }); setCPUMap(cpusMap, id, thread.native_handle()); @@ -194,7 +195,7 @@ int RecThreadInfo::runThreads() const auto cpusMap = parseCPUMap(); if (RecThreadInfo::numDistributors() + RecThreadInfo::numWorkers() == 1) { - g_log << Logger::Warning << "Operating unthreaded" << endl; + g_log << Logger::Warning << "Operating with single distributor/worker thread" << endl; #ifdef HAVE_SYSTEMD sd_notify(0, "READY=1"); @@ -206,7 +207,7 @@ int RecThreadInfo::runThreads() handlerInfo.start(0, "web+stat", cpusMap); auto& taskInfo = RecThreadInfo::info(2); taskInfo.setTaskThread(); - taskInfo.start(2, "tasks", cpusMap); + taskInfo.start(2, "taskThread", cpusMap); auto& info = RecThreadInfo::info(currentThreadId); info.setListener(); @@ -1797,7 +1798,10 @@ static void handleRCC(int fd, FDMultiplexer::funcparam_t& var) static void houseKeeping(void*) { static thread_local time_t t_last_trustAnchorUpdate{0}; // all threads - static thread_local struct timeval t_last_prune{0, 0}; // all threads + static thread_local struct timeval t_last_prune + { + 0, 0 + }; // all threads static thread_local int t_cleanCounter{0}; // all threads static thread_local bool t_running{false}; // houseKeeping can get suspended in secpoll, and be restarted, which makes us do duplicate work auto luaconfsLocal = g_luaconfs.getLocal(); diff --git a/pdns/recursordist/rec-main.hh b/pdns/recursordist/rec-main.hh index d21c63e583..bfc1283ad2 100644 --- a/pdns/recursordist/rec-main.hh +++ b/pdns/recursordist/rec-main.hh @@ -384,6 +384,11 @@ public: t_id = id; } + std::string getname() const + { + return name; + } + static unsigned int numHandlers() { return 1; @@ -466,6 +471,7 @@ private: bool taskThread{false}; static thread_local unsigned int t_id; + std::string name; static std::vector s_threadInfos; static bool s_weDistributeQueries; // if true, 1 or more threads listen on the incoming query sockets and distribute them to workers static unsigned int s_numDistributorThreads;