mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
Lock before checking if orphan_work_set is empty; indicate it is guarded
This commit is contained in:
parent
8803aee668
commit
673247b58c
1 changed files with 9 additions and 4 deletions
|
@ -513,7 +513,7 @@ struct Peer {
|
||||||
bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false};
|
bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false};
|
||||||
|
|
||||||
/** Set of txids to reconsider once their parent transactions have been accepted **/
|
/** Set of txids to reconsider once their parent transactions have been accepted **/
|
||||||
std::set<uint256> m_orphan_work_set;
|
std::set<uint256> m_orphan_work_set GUARDED_BY(g_cs_orphans);
|
||||||
|
|
||||||
Peer(NodeId id) : m_id(id) {}
|
Peer(NodeId id) : m_id(id) {}
|
||||||
};
|
};
|
||||||
|
@ -3876,10 +3876,12 @@ bool PeerManager::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgP
|
||||||
if (!pfrom->vRecvGetData.empty())
|
if (!pfrom->vRecvGetData.empty())
|
||||||
ProcessGetData(*pfrom, m_chainparams, m_connman, m_mempool, interruptMsgProc);
|
ProcessGetData(*pfrom, m_chainparams, m_connman, m_mempool, interruptMsgProc);
|
||||||
|
|
||||||
if (!peer->m_orphan_work_set.empty()) {
|
{
|
||||||
LOCK2(cs_main, g_cs_orphans);
|
LOCK2(cs_main, g_cs_orphans);
|
||||||
|
if (!peer->m_orphan_work_set.empty()) {
|
||||||
ProcessOrphanTx(peer->m_orphan_work_set);
|
ProcessOrphanTx(peer->m_orphan_work_set);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pfrom->fDisconnect)
|
if (pfrom->fDisconnect)
|
||||||
return false;
|
return false;
|
||||||
|
@ -3887,7 +3889,10 @@ bool PeerManager::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgP
|
||||||
// this maintains the order of responses
|
// this maintains the order of responses
|
||||||
// and prevents vRecvGetData to grow unbounded
|
// and prevents vRecvGetData to grow unbounded
|
||||||
if (!pfrom->vRecvGetData.empty()) return true;
|
if (!pfrom->vRecvGetData.empty()) return true;
|
||||||
|
{
|
||||||
|
LOCK(g_cs_orphans);
|
||||||
if (!peer->m_orphan_work_set.empty()) return true;
|
if (!peer->m_orphan_work_set.empty()) return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Don't bother if send buffer is too full to respond anyway
|
// Don't bother if send buffer is too full to respond anyway
|
||||||
if (pfrom->fPauseSend)
|
if (pfrom->fPauseSend)
|
||||||
|
|
Loading…
Add table
Reference in a new issue