From: Pieter Lexis Date: Thu, 27 Sep 2018 09:34:25 +0000 (+0200) Subject: dnsdist: name all threads X-Git-Tag: dnsdist-1.3.3~68^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77c9bc9a96f425e832796774e9ab121639d92f8f;p=thirdparty%2Fpdns.git dnsdist: name all threads --- diff --git a/pdns/delaypipe.cc b/pdns/delaypipe.cc index aebf217c79..e4e557bc7b 100644 --- a/pdns/delaypipe.cc +++ b/pdns/delaypipe.cc @@ -23,6 +23,7 @@ #include "misc.hh" #include "gettime.hh" #include +#include "dolog.hh" template ObjectPipe::ObjectPipe() @@ -138,6 +139,11 @@ DelayPipe::~DelayPipe() template void DelayPipe::worker() { + string threadName = "dnsdist/delayPi"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for DelayPipe worker thread: %s", threadName, strerror(retval)); + } Combo c; for(;;) { /* this code is slightly too subtle, but I don't see how it could be any simpler. diff --git a/pdns/dnsdist-carbon.cc b/pdns/dnsdist-carbon.cc index 860657d586..c880289d50 100644 --- a/pdns/dnsdist-carbon.cc +++ b/pdns/dnsdist-carbon.cc @@ -39,6 +39,11 @@ uint64_t uptimeOfProcess(const std::string& str) void* carbonDumpThread() try { + string threadName = "dnsdist/carbon"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for carbon thread: %s", threadName, strerror(retval)); + } auto localCarbon = g_carbon.getLocal(); for(int numloops=0;;++numloops) { if(localCarbon->empty()) { diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index 4eda5b0553..c9fe6f4f97 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -535,6 +535,11 @@ char** my_completion( const char * text , int start, int end) static void controlClientThread(int fd, ComboAddress client) try { + string threadname = "dnsdist/conscli"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadname.c_str())); + if (retval != 0) { + warnlog("could not set thread name %s for control client thread: %s", threadname, strerror(retval)); + } setTCPNoDelay(fd); SodiumNonce theirs, ours, readingNonce, writingNonce; ours.init(); @@ -665,6 +670,11 @@ catch(std::exception& e) void controlThread(int fd, ComboAddress local) try { + string threadName = "dnsdist/control"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for control console thread: %s", threadName, strerror(retval)); + } ComboAddress client; int sock; auto localACL = g_consoleACL.getLocal(); diff --git a/pdns/dnsdist-lua-actions.cc b/pdns/dnsdist-lua-actions.cc index 377add214c..4dd98797d1 100644 --- a/pdns/dnsdist-lua-actions.cc +++ b/pdns/dnsdist-lua-actions.cc @@ -19,6 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include "dnsdist.hh" #include "dnsdist-ecs.hh" #include "dnsdist-lua.hh" @@ -211,6 +212,11 @@ std::map TeeAction::getStats() const void TeeAction::worker() { + string threadName = "dnsdist/TeeWork"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for TeeAction worker thread: %s", threadName, strerror(retval)); + } char packet[1500]; int res=0; struct dnsheader* dh=(struct dnsheader*)packet; diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 5ca8ba0717..69d653d4bb 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -237,6 +237,12 @@ void* tcpClientThread(int pipefd) /* we get launched with a pipe on which we receive file descriptors from clients that we own from that point on */ + string threadName = "dnsdist/tcpClie"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for TCP Client thread: %s", threadName, strerror(retval)); + } + bool outstanding = false; time_t lastTCPCleanup = time(nullptr); @@ -670,6 +676,11 @@ void* tcpClientThread(int pipefd) */ void* tcpAcceptorThread(void* p) { + string threadName = "dnsdist/tcpAcce"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for TCP acceptor thread: %s", threadName, strerror(retval)); + } ClientState* cs = (ClientState*) p; bool tcpClientCountIncremented = false; ComboAddress remote; diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index e2e756c8ea..4be3811958 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -25,6 +25,7 @@ #include "ext/incbin/incbin.h" #include "dolog.hh" #include +#include #include #include #include "namespaces.hh" @@ -242,6 +243,12 @@ static json11::Json::array someResponseRulesToJson(GlobalStateHolder>* static void connectionThread(int sock, ComboAddress remote, string password, string apiKey, const boost::optional >& customHeaders) { + string threadName = "dnsdist/webConn"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for webserver connection thread: %s", threadName, strerror(retval)); + } + using namespace json11; vinfolog("Webserver handling connection from %s", remote.toStringWithPort()); @@ -813,6 +820,11 @@ static void connectionThread(int sock, ComboAddress remote, string password, str } void dnsdistWebserverThread(int sock, const ComboAddress& local, const std::string& password, const std::string& apiKey, const boost::optional >& customHeaders) { + string threadName = "dnsdist/webserv"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for webserver thread: %s", threadName, strerror(retval)); + } warnlog("Webserver launched on %s", local.toStringWithPort()); for(;;) { try { diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 4173879f6d..7cf206ffb1 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -426,6 +426,11 @@ static void pickBackendSocketsReadyForReceiving(const std::shared_ptr dss) try { + string threadName = "dnsdist/respond"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for responder thread: %s", threadName, strerror(retval)); + } auto localRespRulactions = g_resprulactions.getLocal(); #ifdef HAVE_DNSCRYPT char packet[4096 + DNSCRYPT_MAX_RESPONSE_PADDING_AND_MAC_SIZE]; @@ -1655,6 +1660,11 @@ static void MultipleMessagesUDPClientThread(ClientState* cs, LocalHolders& holde static void* udpClientThread(ClientState* cs) try { + string threadName = "dnsdist/udpClie"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for UDP client thread: %s", threadName, strerror(retval)); + } LocalHolders holders; #if defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE) @@ -1850,6 +1860,11 @@ std::atomic g_cacheCleaningPercentage{100}; void* maintThread() { + string threadName = "dnsdist/main"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for main thread: %s", threadName, strerror(retval)); + } int interval = 1; size_t counter = 0; int32_t secondsToWaitLog = 0; @@ -1896,6 +1911,12 @@ void* maintThread() void* healthChecksThread() { + string threadName = "dnsdist/healthC"; + auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); + if (retval != 0) { + warnlog("Could not set thread name %s for health check thread: %s", threadName, strerror(retval)); + } + int interval = 1; for(;;) { diff --git a/pdns/remote_logger.cc b/pdns/remote_logger.cc index c186e017a9..657c493b73 100644 --- a/pdns/remote_logger.cc +++ b/pdns/remote_logger.cc @@ -42,10 +42,18 @@ void RemoteLogger::busyReconnectLoop() void RemoteLogger::worker() { +#ifdef WE_ARE_RECURSOR string threadName = "pdns-r/remLog"; +#else + string threadName = "dnsdist/remLog"; +#endif auto retval = pthread_setname_np(pthread_self(), const_cast(threadName.c_str())); if (retval != 0) { +#ifdef WE_ARE_RECURSOR g_log<(threadName.c_str())); if (retval != 0) { +#ifdef RECURSOR g_log<