From 1e78f566d575a047a6f0b762bc79601e0208d103 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Wed, 7 Sep 2022 13:57:18 +1000 Subject: net: add NetEventsInterface::g_msgproc_mutex There are many cases where we assume message processing is single-threaded in order for how we access node-related memory to be safe. Add an explicit mutex that we can use to document this, which allows the compiler to catch any cases where we try to access that memory from other threads and break that assumption. --- src/net.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/net.cpp') diff --git a/src/net.cpp b/src/net.cpp index 6659b64246..02b4ecb593 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1978,8 +1978,12 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai } } +Mutex NetEventsInterface::g_msgproc_mutex; + void CConnman::ThreadMessageHandler() { + LOCK(NetEventsInterface::g_msgproc_mutex); + SetSyscallSandboxPolicy(SyscallSandboxPolicy::MESSAGE_HANDLER); while (!flagInterruptMsgProc) { -- cgit v1.2.3