]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Make ping reply with thread name
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 31 Jan 2022 09:46:36 +0000 (10:46 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 4 Feb 2022 10:06:17 +0000 (11:06 +0100)
pdns/rec_channel_rec.cc
pdns/recursordist/rec-main.cc
pdns/recursordist/rec-main.hh

index 9523d738b94a2dd8b08ac68a1cd740bbb9b8e5f7..b03c3146082d51deed9cc34a994fd67b0e85f5dc 100644 (file)
@@ -1669,7 +1669,7 @@ static string doGenericTopQueries(pleasequeryfunc_t func, boost::function<DNSNam
 
 static string* nopFunction()
 {
-  return new string("pong\n");
+  return new string("pong " + RecThreadInfo::self().getname() + '\n');
 }
 
 static string getDontThrottleNames()
index fda1340d72bf197bfce5881f25c029e5cb5488e6..c03fab9164b6951709aa37303f34e18b143c3a6b 100644 (file)
@@ -176,12 +176,13 @@ static void setCPUMap(const std::map<unsigned int, std::set<int>>& cpusMap, unsi
 
 static void recursorThread();
 
-void RecThreadInfo::start(unsigned int id, const string& name, const std::map<unsigned int, std::set<int>>& cpusMap)
+void RecThreadInfo::start(unsigned int id, const string& tname, const std::map<unsigned int, std::set<int>>& 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();
index d21c63e5835b6e180d7d1d3c279951196ff9f991..bfc1283ad26dcce47197ae25ca41fe1a82a60e7c 100644 (file)
@@ -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<RecThreadInfo> 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;