From: Remi Gacogne Date: Thu, 3 May 2018 14:01:46 +0000 (+0100) Subject: rec: Use constants for the handler and distributor thread ids X-Git-Tag: dnsdist-1.3.1~89^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=faf580f5899d0bfacd8410a5565165f103cb77ec;p=pdns rec: Use constants for the handler and distributor thread ids --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index d26b08ff9..6769a5cd2 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -132,6 +132,9 @@ struct ThreadPipeSet int readQueriesToThread; }; +static const int s_handlerThreadID = -1; +static const int s_distributorThreadID = 0; + typedef vector tcpListenSockets_t; typedef map listenSocketsAddresses_t; // is shared across all threads right now typedef vector > > deferredAdd_t; @@ -2356,13 +2359,13 @@ static void houseKeeping(void *) last_rootupdate=now.tv_sec; } - if (t_id == -1) { + if (t_id == s_handlerThreadID) { if(g_statisticsInterval > 0 && now.tv_sec - last_stat >= g_statisticsInterval) { doStats(); last_stat=time(0); } } - else if(!t_id) { + else if(t_id == s_distributorThreadID) { if(now.tv_sec - last_secpoll >= 3600) { try { @@ -2435,7 +2438,7 @@ struct ThreadMSG void broadcastFunction(const pipefunc_t& func, bool skipSelf) { /* This function might be called by the worker with t_id 0 during startup */ - if (t_id != -1 && t_id != 0) { + if (t_id != s_handlerThreadID && t_id != s_distributorThreadID) { g_log< >& operator+=(vector >&a, template T broadcastAccFunction(const boost::function& func, bool skipSelf) { - if (t_id != -1) { + if (t_id != s_handlerThreadID) { g_log<addReadFD(i->first, i->second); } @@ -3546,7 +3549,7 @@ try t_fdm->run(&g_now); // 'run' updates g_now for us - if(worker && (!g_weDistributeQueries || !t_id)) { // if pdns distributes queries, only tid 0 should do this + if(worker && (!g_weDistributeQueries || t_id == s_distributorThreadID)) { // if pdns distributes queries, only tid 0 should do this if(listenOnTCP) { if(TCPConnection::getCurrentConnections() > maxTcpClients) { // shutdown, too many connections for(tcpListenSockets_t::iterator i=g_tcpListenSockets.begin(); i != g_tcpListenSockets.end(); ++i)