Skip to content

Commit c3cf2f5

Browse files
committed
rpc/blockchain.cpp: Remove g_utxosetscan mutex that is only protecting a single atomic variable
1 parent d96fdc2 commit c3cf2f5

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/rpc/blockchain.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,6 @@ bool FindScriptPubKey(std::atomic<int>& scan_progress, const std::atomic<bool>&
19761976
}
19771977

19781978
/** RAII object to prevent concurrency issue when scanning the txout set */
1979-
static std::mutex g_utxosetscan;
19801979
static std::atomic<int> g_scan_progress;
19811980
static std::atomic<bool> g_scan_in_progress;
19821981
static std::atomic<bool> g_should_abort_scan;
@@ -1989,18 +1988,15 @@ class CoinsViewScanReserver
19891988

19901989
bool reserve() {
19911990
CHECK_NONFATAL(!m_could_reserve);
1992-
std::lock_guard<std::mutex> lock(g_utxosetscan);
1993-
if (g_scan_in_progress) {
1991+
if (g_scan_in_progress.exchange(true)) {
19941992
return false;
19951993
}
1996-
g_scan_in_progress = true;
19971994
m_could_reserve = true;
19981995
return true;
19991996
}
20001997

20011998
~CoinsViewScanReserver() {
20021999
if (m_could_reserve) {
2003-
std::lock_guard<std::mutex> lock(g_utxosetscan);
20042000
g_scan_in_progress = false;
20052001
}
20062002
}

0 commit comments

Comments
 (0)