Skip to content

Commit 6c10037

Browse files
rpc: Fix data race (UB) in InterruptRPC()
1 parent f055389 commit 6c10037

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/rpc/server.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <unordered_map>
2525

2626
static CCriticalSection cs_rpcWarmup;
27-
static bool fRPCRunning = false;
27+
static std::atomic<bool> g_rpc_running{false};
2828
static bool fRPCInWarmup GUARDED_BY(cs_rpcWarmup) = true;
2929
static std::string rpcWarmupStatus GUARDED_BY(cs_rpcWarmup) = "RPC server started";
3030
/* Timer-creating functions */
@@ -303,15 +303,15 @@ bool CRPCTable::appendCommand(const std::string& name, const CRPCCommand* pcmd)
303303
void StartRPC()
304304
{
305305
LogPrint(BCLog::RPC, "Starting RPC\n");
306-
fRPCRunning = true;
306+
g_rpc_running = true;
307307
g_rpcSignals.Started();
308308
}
309309

310310
void InterruptRPC()
311311
{
312312
LogPrint(BCLog::RPC, "Interrupting RPC\n");
313313
// Interrupt e.g. running longpolls
314-
fRPCRunning = false;
314+
g_rpc_running = false;
315315
}
316316

317317
void StopRPC()
@@ -324,7 +324,7 @@ void StopRPC()
324324

325325
bool IsRPCRunning()
326326
{
327-
return fRPCRunning;
327+
return g_rpc_running;
328328
}
329329

330330
void SetRPCWarmupStatus(const std::string& newStatus)

test/sanitizer_suppressions/tsan

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ deadlock:WalletBatch
77
# Intentional deadlock in tests
88
deadlock:TestPotentialDeadLockDetected
99

10-
# fRPCRunning race
11-
race:InterruptRPC
12-
1310
# Wildcard for all gui tests, should be replaced with non-wildcard suppressions
1411
race:src/qt/test/*
1512
deadlock:src/qt/test/*

0 commit comments

Comments
 (0)