Skip to content

Commit

Permalink
rpc: Fix data race (UB) in InterruptRPC()
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift committed Dec 18, 2018
1 parent f055389 commit 6c10037
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -303,15 +303,15 @@ 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();
}

void InterruptRPC()
{
LogPrint(BCLog::RPC, "Interrupting RPC\n");
// Interrupt e.g. running longpolls
fRPCRunning = false;
g_rpc_running = false;
}

void StopRPC()
Expand All @@ -324,7 +324,7 @@ void StopRPC()

bool IsRPCRunning()
{
return fRPCRunning;
return g_rpc_running;
}

void SetRPCWarmupStatus(const std::string& newStatus)
Expand Down
3 changes: 0 additions & 3 deletions test/sanitizer_suppressions/tsan
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down

0 comments on commit 6c10037

Please sign in to comment.