aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2022-09-07 13:57:18 +1000
committerAnthony Towns <aj@erisian.com.au>2022-09-15 14:44:38 +1000
commit1e78f566d575a047a6f0b762bc79601e0208d103 (patch)
treee704563542df1527232220842839705aa9f24fd8 /src/net.cpp
parent124e75a41ea0f3f0e90b63b0c41813184ddce2ab (diff)
downloadbitcoin-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.cpp4
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)
{