Skip to content

Commit 673247b

Browse files
committed
Lock before checking if orphan_work_set is empty; indicate it is guarded
1 parent 8803aee commit 673247b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/net_processing.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ struct Peer {
513513
bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false};
514514

515515
/** Set of txids to reconsider once their parent transactions have been accepted **/
516-
std::set<uint256> m_orphan_work_set;
516+
std::set<uint256> m_orphan_work_set GUARDED_BY(g_cs_orphans);
517517

518518
Peer(NodeId id) : m_id(id) {}
519519
};
@@ -3876,9 +3876,11 @@ bool PeerManager::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgP
38763876
if (!pfrom->vRecvGetData.empty())
38773877
ProcessGetData(*pfrom, m_chainparams, m_connman, m_mempool, interruptMsgProc);
38783878

3879-
if (!peer->m_orphan_work_set.empty()) {
3879+
{
38803880
LOCK2(cs_main, g_cs_orphans);
3881-
ProcessOrphanTx(peer->m_orphan_work_set);
3881+
if (!peer->m_orphan_work_set.empty()) {
3882+
ProcessOrphanTx(peer->m_orphan_work_set);
3883+
}
38823884
}
38833885

38843886
if (pfrom->fDisconnect)
@@ -3887,7 +3889,10 @@ bool PeerManager::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgP
38873889
// this maintains the order of responses
38883890
// and prevents vRecvGetData to grow unbounded
38893891
if (!pfrom->vRecvGetData.empty()) return true;
3890-
if (!peer->m_orphan_work_set.empty()) return true;
3892+
{
3893+
LOCK(g_cs_orphans);
3894+
if (!peer->m_orphan_work_set.empty()) return true;
3895+
}
38913896

38923897
// Don't bother if send buffer is too full to respond anyway
38933898
if (pfrom->fPauseSend)

0 commit comments

Comments
 (0)