]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Name all threads
authorPieter Lexis <pieter.lexis@powerdns.com>
Thu, 27 Sep 2018 11:12:06 +0000 (13:12 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Thu, 27 Sep 2018 11:12:06 +0000 (13:12 +0200)
pdns/auth-carbon.cc
pdns/common_startup.cc
pdns/communicator.cc
pdns/distributor.hh
pdns/dnsproxy.cc
pdns/dynlistener.cc
pdns/tcpreceiver.cc
pdns/ws-auth.cc

index 39137630091c1a1accb7b1c2c4dd16889942813e..f27e6ddb9020bdc762392bc7b66587ef5b878bde 100644 (file)
 void* carbonDumpThread(void*)
 try
 {
+  string threadName = "pdns/carbonDump";
+  auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
+  if (retval != 0) {
+    g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for Carbon dump thread: "<<strerror(retval)<<endl;
+  }
   extern StatBag S;
 
   string hostname=arg()["carbon-ourname"];
index 2a05f069010e1b684e1bd9a2e59c563509b773dd..892cd963d7d327f967373dd3bbe152b3b9a17667 100644 (file)
@@ -367,6 +367,12 @@ void sendout(DNSPacket* a)
 void *qthread(void *number)
 try
 {
+  string threadName = "pdns/receiver";
+  auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
+  if (retval != 0) {
+    g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for receiver thread: "<<strerror(retval)<<endl;
+  }
+
   DNSPacket *P;
   DNSDistributor *distributor = DNSDistributor::Create(::arg().asNum("distributor-threads", 1)); // the big dispatcher!
   int num = (int)(unsigned long)number;
index e521b5d6e2d138706651ec9af02dfabaf5bd50fa..52f1aafdb85e211aae86b40396c50d89da81c4b8 100644 (file)
 // there can be MANY OF THESE
 void CommunicatorClass::retrievalLoopThread(void)
 {
+  string threadName = "pdns/comm-retre";
+  auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
+  if (retval != 0) {
+    g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for retrieval thread: "<<strerror(retval)<<endl;
+  }
   for(;;) {
     d_suck_sem.wait();
     SuckRequest sr;
@@ -104,6 +109,12 @@ void CommunicatorClass::go()
 void CommunicatorClass::mainloop(void)
 {
   try {
+    string threadName = "pdns/comm-main";
+    auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
+    if (retval != 0) {
+      g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for communicator main thread: "<<strerror(retval)<<endl;
+    }
+
     signal(SIGPIPE,SIG_IGN);
     g_log<<Logger::Error<<"Master/slave communicator launching"<<endl;
     PacketHandler P;
index 490602f3e923de7e10631c551036b1b52770d2b7..2abd21684e1fec64c616a8c351bd030fb27646ac 100644 (file)
@@ -173,6 +173,11 @@ template<class Answer, class Question, class Backend>MultiThreadDistributor<Answ
 // start of a new thread
 template<class Answer, class Question, class Backend>void *MultiThreadDistributor<Answer,Question,Backend>::makeThread(void *p)
 {
+  string threadName = "pdns/distributo";
+  auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
+  if (retval != 0) {
+    g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for distributor thread: "<<strerror(retval)<<endl;
+  }
   pthread_detach(pthread_self());
   MultiThreadDistributor *us=static_cast<MultiThreadDistributor *>(p);
   int ournum=us->d_running++;
index aed97610b43925449f424ac35f54f49a72c0a85b..18c3d4c4b2cd756bc825710b6b8bf4fe15761351 100644 (file)
@@ -175,6 +175,11 @@ int DNSProxy::getID_locked()
 
 void DNSProxy::mainloop(void)
 {
+  string threadName = "pdns/dnsproxy";
+  auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
+  if (retval != 0) {
+    g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for DNS proxy thread: "<<strerror(retval)<<endl;
+  }
   try {
     char buffer[1500];
     ssize_t len;
index 04bf537c103cdda167aef645a6a7369ffd0f61c5..05036c803b09d27d04b2b3b84c74f4b23a270cd3 100644 (file)
@@ -216,6 +216,11 @@ void DynListener::go()
 
 void *DynListener::theListenerHelper(void *p)
 {
+  string threadName = "pdns/ctrlListen";
+  auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
+  if (retval != 0) {
+    g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for control socket listener thread: "<<strerror(retval)<<endl;
+  }
   DynListener *us=static_cast<DynListener *>(p);
   us->theListener();
   g_log<<Logger::Error<<"Control listener aborted, please file a bug!"<<endl;
index b3e14d702b60f5bc6b2b23d7fb968e3fd51927e0..1307ae75a98471a7ed08af29f100bff44d9b4be9 100644 (file)
@@ -252,6 +252,11 @@ void TCPNameserver::decrementClientCount(const ComboAddress& remote)
 
 void *TCPNameserver::doConnection(void *data)
 {
+  string threadName = "pdns/tcpConnect";
+  auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
+  if (retval != 0) {
+    g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for TCP nameserver connection thread: "<<strerror(retval)<<endl;
+  }
   shared_ptr<DNSPacket> packet;
   // Fix gcc-4.0 error (on AMD64)
   int fd=(int)(long)data; // gotta love C (generates a harmless warning on opteron)
@@ -1335,6 +1340,11 @@ TCPNameserver::TCPNameserver()
 //! Start of TCP operations thread, we launch a new thread for each incoming TCP question
 void TCPNameserver::thread()
 {
+  string threadName = "pdns/tcpnameser";
+  auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
+  if (retval != 0) {
+    g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for TCP nameserver thread: "<<strerror(retval)<<endl;
+  }
   try {
     for(;;) {
       int fd;
index 09d5fa409d8d9e2742ff754601b28629bf5446a8..abc16e2faee0ece336ceb4b71ff9f28886249de9 100644 (file)
@@ -75,6 +75,11 @@ void AuthWebServer::go()
 void AuthWebServer::statThread()
 {
   try {
+    string threadName = "pdns/statHelper";
+    auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
+    if (retval != 0) {
+      g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for stat helper thread: "<<strerror(retval)<<endl;
+    }
     for(;;) {
       d_queries.submit(S.read("udp-queries"));
       d_cachehits.submit(S.read("packetcache-hit"));
@@ -1949,6 +1954,11 @@ void AuthWebServer::cssfunction(HttpRequest* req, HttpResponse* resp)
 void AuthWebServer::webThread()
 {
   try {
+    string threadName = "pdns/webserver";
+    auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
+    if (retval != 0) {
+      g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for webserver thread: "<<strerror(retval)<<endl;
+    }
     if(::arg().mustDo("api")) {
       d_ws->registerApiHandler("/api/v1/servers/localhost/cache/flush", &apiServerCacheFlush);
       d_ws->registerApiHandler("/api/v1/servers/localhost/config", &apiServerConfig);