diff options
author | Anthony Towns <aj@erisian.com.au> | 2022-09-07 13:57:18 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2022-09-15 14:44:38 +1000 |
commit | 1e78f566d575a047a6f0b762bc79601e0208d103 (patch) | |
tree | e704563542df1527232220842839705aa9f24fd8 /src/net.cpp | |
parent | 124e75a41ea0f3f0e90b63b0c41813184ddce2ab (diff) | |
download | bitcoin-1e78f566d575a047a6f0b762bc79601e0208d103.tar.xz |
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.
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
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) { |