mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
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.
This commit is contained in:
parent
81dd57e5b1
commit
38a11c355a
3 changed files with 6 additions and 5 deletions
|
@ -1003,7 +1003,7 @@ void PeerManagerImpl::FinalizeNode(const CNode& node, bool& fUpdateConnectionTim
|
|||
for (const QueuedBlock& entry : state->vBlocksInFlight) {
|
||||
mapBlocksInFlight.erase(entry.hash);
|
||||
}
|
||||
EraseOrphansFor(nodeid);
|
||||
WITH_LOCK(g_cs_orphans, EraseOrphansFor(nodeid));
|
||||
m_txrequest.DisconnectedPeer(nodeid);
|
||||
nPreferredDownload -= state->fPreferredDownload;
|
||||
nPeersWithValidatedDownloads -= (state->nBlocksInFlightValidHeaders != 0);
|
||||
|
|
|
@ -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<uint256, COrphanTx>::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;
|
||||
|
|
|
@ -24,8 +24,8 @@ struct COrphanTx {
|
|||
};
|
||||
|
||||
int EraseOrphanTx(const uint256& txid) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
|
||||
void EraseOrphansFor(NodeId peer);
|
||||
unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans);
|
||||
void EraseOrphansFor(NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
|
||||
unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
|
||||
|
||||
/** Map from txid to orphan transaction record. Limited by
|
||||
* -maxorphantx/DEFAULT_MAX_ORPHAN_TRANSACTIONS */
|
||||
|
|
Loading…
Add table
Reference in a new issue