From: Otto Moerbeek Date: Mon, 30 Jun 2025 11:02:35 +0000 (+0200) Subject: rec: don't let rust code and handler use thread pipes simultaneously X-Git-Tag: rec-5.3.0-alpha2~28^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e22b50dfcdca0bc9a5f107eaaffa1d3635212462;p=thirdparty%2Fpdns.git rec: don't let rust code and handler use thread pipes simultaneously Signed-off-by: Otto Moerbeek --- diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index f910571c77..c4f73cb951 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -1524,8 +1524,13 @@ void parseACLs() l_initialized = true; } +static std::mutex pipeBroadCastMutex{}; + void broadcastFunction(const pipefunc_t& func) { + // we do not want the handler and web code to use pipes simultaneously + std::lock_guard lock(pipeBroadCastMutex); + /* This function might be called by the worker with t_id not inited during startup for the initialization of ACLs and domain maps. After that it should only be called by the handler. */ @@ -1603,11 +1608,10 @@ static RemoteLoggerStats_t& operator+=(RemoteLoggerStats_t& lhs, const RemoteLog return lhs; } -// 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, and by the SNMP thread to gather -// metrics. -// Note that this currently skips the handler, but includes the taskThread(s). +// This function should only be called by the handler and web thread to gather metrics, wipe the +// cache, reload the Lua script (not the Lua config) or change the current trace regex, and by the +// SNMP thread to gather metrics. Note that this currently skips the handler, but includes the +// taskThread(s). template T broadcastAccFunction(const std::function& func) { @@ -1616,6 +1620,9 @@ T broadcastAccFunction(const std::function& func) _exit(1); } + // we do not want the handler and web code to use pipes simultaneously + std::lock_guard lock(pipeBroadCastMutex); + unsigned int thread = 0; T ret = T(); for (const auto& threadInfo : RecThreadInfo::infos()) {