From 38a11c355acfc15134c682571b3d92f66b0e7c3c Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Mon, 1 Feb 2021 01:35:08 +1000 Subject: txorphanage: Add lock annotations EraseOrphansFor was called both with and without g_cs_orphans held, correct that so that it's always called with it already held. LimitOrphanTxSize was always called with g_cs_orphans held, so add annotations and don't lock it a second time. --- src/txorphanage.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/txorphanage.cpp') diff --git a/src/txorphanage.cpp b/src/txorphanage.cpp index d418ed9323..c883aaa57f 100644 --- a/src/txorphanage.cpp +++ b/src/txorphanage.cpp @@ -55,7 +55,8 @@ int EraseOrphanTx(const uint256& txid) void EraseOrphansFor(NodeId peer) { - LOCK(g_cs_orphans); + AssertLockHeld(g_cs_orphans); + int nErased = 0; std::map::iterator iter = mapOrphanTransactions.begin(); while (iter != mapOrphanTransactions.end()) @@ -71,7 +72,7 @@ void EraseOrphansFor(NodeId peer) unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) { - LOCK(g_cs_orphans); + AssertLockHeld(g_cs_orphans); unsigned int nEvicted = 0; static int64_t nNextSweep; -- cgit v1.2.3