]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: don't let rust code and handler use thread pipes simultaneously 15752/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 30 Jun 2025 11:02:35 +0000 (13:02 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 30 Jun 2025 11:02:35 +0000 (13:02 +0200)
Signed-off-by: Otto Moerbeek <otto.moerbeek@open-xchange.com>
pdns/recursordist/rec-main.cc

index f910571c778d1460c10a6648df56ee75a8865585..c4f73cb95163c6be3fb9104c276c170e70947186 100644 (file)
@@ -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 <class T>
 T broadcastAccFunction(const std::function<T*()>& func)
 {
@@ -1616,6 +1620,9 @@ T broadcastAccFunction(const std::function<T*()>& 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()) {