aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2018-12-18 10:21:06 +0100
committerpracticalswift <practicalswift@users.noreply.github.com>2018-12-18 18:52:12 +0100
commit6c10037f72073eecc674c313580ef50a4f1e1e44 (patch)
tree3b081af3fe7bf862c253e06dd5a9297895f5b08a
parentf055389cb9572ed96c93722f451dfb37e7f1f9a2 (diff)
rpc: Fix data race (UB) in InterruptRPC()
-rw-r--r--src/rpc/server.cpp8
-rw-r--r--test/sanitizer_suppressions/tsan3
2 files changed, 4 insertions, 7 deletions
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 733f8601ee..03e1c81132 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -24,7 +24,7 @@
#include <unordered_map>
static CCriticalSection cs_rpcWarmup;
-static bool fRPCRunning = false;
+static std::atomic<bool> g_rpc_running{false};
static bool fRPCInWarmup GUARDED_BY(cs_rpcWarmup) = true;
static std::string rpcWarmupStatus GUARDED_BY(cs_rpcWarmup) = "RPC server started";
/* Timer-creating functions */
@@ -303,7 +303,7 @@ bool CRPCTable::appendCommand(const std::string& name, const CRPCCommand* pcmd)
void StartRPC()
{
LogPrint(BCLog::RPC, "Starting RPC\n");
- fRPCRunning = true;
+ g_rpc_running = true;
g_rpcSignals.Started();
}
@@ -311,7 +311,7 @@ void InterruptRPC()
{
LogPrint(BCLog::RPC, "Interrupting RPC\n");
// Interrupt e.g. running longpolls
- fRPCRunning = false;
+ g_rpc_running = false;
}
void StopRPC()
@@ -324,7 +324,7 @@ void StopRPC()
bool IsRPCRunning()
{
- return fRPCRunning;
+ return g_rpc_running;
}
void SetRPCWarmupStatus(const std::string& newStatus)
diff --git a/test/sanitizer_suppressions/tsan b/test/sanitizer_suppressions/tsan
index 593e1f54ff..70eea34363 100644
--- a/test/sanitizer_suppressions/tsan
+++ b/test/sanitizer_suppressions/tsan
@@ -7,9 +7,6 @@ deadlock:WalletBatch
# Intentional deadlock in tests
deadlock:TestPotentialDeadLockDetected
-# fRPCRunning race
-race:InterruptRPC
-
# Wildcard for all gui tests, should be replaced with non-wildcard suppressions
race:src/qt/test/*
deadlock:src/qt/test/*