From 388604e4779dd0f1297d943320ae389c65a13e02 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 (cherry picked from commit 788eeb4c3318f5f6827943e4953941f48b2dc22a) --- 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 6175af2f2e..4cfb5bd573 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -97,7 +97,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; @@ -2257,18 +2257,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) { L< >& 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) { - L<