From b4e76a18dbfdf42217f2341b4b967bc6a8aec6f5 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Thu, 3 May 2018 15:16:25 +0100 Subject: [PATCH] rec: Fix ACL and domain map updates in the handler thread --- pdns/pdns_recursor.cc | 18 ++++++++++-------- pdns/syncres.hh | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 6769a5cd2..d0f68a5ca 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -2435,7 +2435,7 @@ struct ThreadMSG bool wantAnswer; }; -void broadcastFunction(const pipefunc_t& func, bool skipSelf) +void broadcastFunction(const pipefunc_t& func) { /* This function might be called by the worker with t_id 0 during startup */ if (t_id != s_handlerThreadID && t_id != s_distributorThreadID) { @@ -2443,12 +2443,14 @@ void broadcastFunction(const pipefunc_t& func, bool skipSelf) exit(1); } + // call the function ourselves, to update the ACL or domain maps for example + func(); + int n = 0; for(ThreadPipeSet& tps : g_pipes) { if(n++ == t_id) { - if(!skipSelf) - func(); // don't write to ourselves! + func(); // don't write to ourselves! continue; } @@ -2563,7 +2565,7 @@ vector >& operator+=(vector >&a, } -template T broadcastAccFunction(const boost::function& func, bool skipSelf) +template T broadcastAccFunction(const boost::function& func) { if (t_id != s_handlerThreadID) { g_log< T broadcastAccFunction(const boost::function& func, bool return ret; } -template string broadcastAccFunction(const boost::function& fun, bool skipSelf); // explicit instantiation -template uint64_t broadcastAccFunction(const boost::function& fun, bool skipSelf); // explicit instantiation -template vector broadcastAccFunction(const boost::function *()>& fun, bool skipSelf); // explicit instantiation -template vector > broadcastAccFunction(const boost::function > *()>& fun, bool skipSelf); // explicit instantiation +template string broadcastAccFunction(const boost::function& fun); // explicit instantiation +template uint64_t broadcastAccFunction(const boost::function& fun); // explicit instantiation +template vector broadcastAccFunction(const boost::function *()>& fun); // explicit instantiation +template vector > broadcastAccFunction(const boost::function > *()>& fun); // explicit instantiation static void handleRCC(int fd, FDMultiplexer::funcparam_t& var) { diff --git a/pdns/syncres.hh b/pdns/syncres.hh index b1fc80c09..d912e9594 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -979,12 +979,12 @@ std::string reloadAuthAndForwards(); ComboAddress parseIPAndPort(const std::string& input, uint16_t port); ComboAddress getQueryLocalAddress(int family, uint16_t port); typedef boost::function pipefunc_t; -void broadcastFunction(const pipefunc_t& func, bool skipSelf = false); +void broadcastFunction(const pipefunc_t& func); void distributeAsyncFunction(const std::string& question, const pipefunc_t& func); int directResolve(const DNSName& qname, const QType& qtype, int qclass, vector& ret); -template T broadcastAccFunction(const boost::function& func, bool skipSelf=false); +template T broadcastAccFunction(const boost::function& func); std::shared_ptr parseAuthAndForwards(); uint64_t* pleaseGetNsSpeedsSize(); -- 2.40.0