From b96f3e794bf78df30a37ba16521b0417c19f1c3e Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 19 Oct 2023 20:35:47 +0700 Subject: [PATCH] fix: missing changes from "merge bitcoin#16127: more thread safety annotation coverage" --- src/rpc/blockchain.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index ac9cc34e9b..45bbe0a96a 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -466,7 +466,6 @@ static UniValue waitforblockheight(const JSONRPCRequest& request) cond_blockchange.wait(lock, [&height]() EXCLUSIVE_LOCKS_REQUIRED(cs_blockchange) {return latestblock.height >= height || !IsRPCRunning(); }); block = latestblock; } - // TODO: Backport g_utxosetscan and associated logic from #16127 UniValue ret(UniValue::VOBJ); ret.pushKV("hash", block.hash.GetHex()); ret.pushKV("height", block.height); @@ -2577,7 +2576,6 @@ bool FindScriptPubKey(std::atomic& scan_progress, const std::atomic& } // namespace /** 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; @@ -2590,18 +2588,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; } }