From 788eeb4c3318f5f6827943e4953941f48b2dc22a Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 6 Jun 2018 16:05:20 +0200 Subject: [PATCH] rec: Allow the SNMP thread to retrieve statistics --- pdns/pdns_recursor.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 3c6a9b189..41700632e 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -101,7 +101,7 @@ typedef map tcpClientCounts_t; static thread_local std::shared_ptr t_pdl; -static thread_local int t_id; +static thread_local int t_id = -1; static thread_local std::shared_ptr t_traceRegex; static thread_local std::unique_ptr t_tcpClientCounts; #ifdef HAVE_PROTOBUF @@ -2475,18 +2475,17 @@ struct ThreadMSG void broadcastFunction(const pipefunc_t& func) { - /* This function might be called by the worker with t_id 0 during startup - for the initialization of ACLs and domain maps */ - if (t_id != s_handlerThreadID && t_id != s_distributorThreadID) { + /* This function might be called before t_id are set during startup + for the initialization of ACLs and domain maps, but the default is the same + than the handler thread */ + if (t_id != s_handlerThreadID) { g_log< >& operator+=(vector >&a, /* This function should only be called by the handler to gather metrics, wipe the cache, - reload the Lua script (not the Lua config) or change the current trace regex */ + reload the Lua script (not the Lua config) or change the current trace regex, + and by the SNMP thread to gather metrics. */ template T broadcastAccFunction(const boost::function& func) { + /* the SNMP thread uses id -1 too */ if (t_id != s_handlerThreadID) { - g_log<