From c3cf2f55013c4ea1c1ef4a878fc7ff8e92f2c42d Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Tue, 11 Feb 2020 14:54:50 +1000 Subject: [PATCH] rpc/blockchain.cpp: Remove g_utxosetscan mutex that is only protecting a single atomic variable --- src/rpc/blockchain.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index f7ccbae7066..d43c22e4da3 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1976,7 +1976,6 @@ bool FindScriptPubKey(std::atomic& scan_progress, const std::atomic& } /** RAII object to prevent concurrency issue when scanning the txout set */ -static std::mutex g_utxosetscan; static std::atomic g_scan_progress; static std::atomic g_scan_in_progress; static std::atomic g_should_abort_scan; @@ -1989,18 +1988,15 @@ public: bool reserve() { CHECK_NONFATAL(!m_could_reserve); - std::lock_guard lock(g_utxosetscan); - if (g_scan_in_progress) { + if (g_scan_in_progress.exchange(true)) { return false; } - g_scan_in_progress = true; m_could_reserve = true; return true; } ~CoinsViewScanReserver() { if (m_could_reserve) { - std::lock_guard lock(g_utxosetscan); g_scan_in_progress = false; } }