From 0d0e0a39b4a58fc48d2f0107e8c08bece58130bc Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 6 May 2025 15:39:12 +0000 Subject: [PATCH] threading: use a reverse lock rather than manual critsect macros No functional change. --- src/rpc/mining.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 36adf154f15..b710c605bcb 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -704,7 +704,7 @@ static RPCHelpMan getblocktemplate() NodeContext& node = EnsureAnyNodeContext(request.context); ChainstateManager& chainman = EnsureChainman(node); Mining& miner = EnsureMining(node); - LOCK(cs_main); + WAIT_LOCK(cs_main, csmain_lock); uint256 tip{CHECK_NONFATAL(miner.getTip()).value().hash}; std::string strMode = "template"; @@ -810,8 +810,8 @@ static RPCHelpMan getblocktemplate() } // Release lock while waiting - LEAVE_CRITICAL_SECTION(cs_main); { + REVERSE_LOCK(csmain_lock, cs_main); MillisecondsDouble checktxtime{std::chrono::minutes(1)}; while (IsRPCRunning()) { // If hashWatchedChain is not a real block hash, this will @@ -830,8 +830,6 @@ static RPCHelpMan getblocktemplate() checktxtime = std::chrono::seconds(10); } } - ENTER_CRITICAL_SECTION(cs_main); - tip = CHECK_NONFATAL(miner.getTip()).value().hash; if (!IsRPCRunning())