Skip to content

Commit 0d0e0a3

Browse files
committed
threading: use a reverse lock rather than manual critsect macros
No functional change.
1 parent 3ddd554 commit 0d0e0a3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/rpc/mining.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ static RPCHelpMan getblocktemplate()
704704
NodeContext& node = EnsureAnyNodeContext(request.context);
705705
ChainstateManager& chainman = EnsureChainman(node);
706706
Mining& miner = EnsureMining(node);
707-
LOCK(cs_main);
707+
WAIT_LOCK(cs_main, csmain_lock);
708708
uint256 tip{CHECK_NONFATAL(miner.getTip()).value().hash};
709709

710710
std::string strMode = "template";
@@ -810,8 +810,8 @@ static RPCHelpMan getblocktemplate()
810810
}
811811

812812
// Release lock while waiting
813-
LEAVE_CRITICAL_SECTION(cs_main);
814813
{
814+
REVERSE_LOCK(csmain_lock, cs_main);
815815
MillisecondsDouble checktxtime{std::chrono::minutes(1)};
816816
while (IsRPCRunning()) {
817817
// If hashWatchedChain is not a real block hash, this will
@@ -830,8 +830,6 @@ static RPCHelpMan getblocktemplate()
830830
checktxtime = std::chrono::seconds(10);
831831
}
832832
}
833-
ENTER_CRITICAL_SECTION(cs_main);
834-
835833
tip = CHECK_NONFATAL(miner.getTip()).value().hash;
836834

837835
if (!IsRPCRunning())

0 commit comments

Comments
 (0)