aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorNeha Narula <narula@gmail.com>2020-09-13 19:34:52 -0400
committerNeha Narula <narula@gmail.com>2020-10-14 10:08:44 -0400
commit673247b58cd1252ab7e99f7d63ead05cc100cef2 (patch)
tree455a12748f64272b30c9c207182ae9d58336bb25 /src/net_processing.cpp
parent8803aee66813d27ddbdfce937ab9c35f8f7c35bc (diff)
Lock before checking if orphan_work_set is empty; indicate it is guarded
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index ab3c323b0f..1a50c68a26 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -513,7 +513,7 @@ struct Peer {
bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false};
/** 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) {}
};
@@ -3876,9 +3876,11 @@ bool PeerManager::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgP
if (!pfrom->vRecvGetData.empty())
ProcessGetData(*pfrom, m_chainparams, m_connman, m_mempool, interruptMsgProc);
- if (!peer->m_orphan_work_set.empty()) {
+ {
LOCK2(cs_main, g_cs_orphans);
- ProcessOrphanTx(peer->m_orphan_work_set);
+ if (!peer->m_orphan_work_set.empty()) {
+ ProcessOrphanTx(peer->m_orphan_work_set);
+ }
}
if (pfrom->fDisconnect)
@@ -3887,7 +3889,10 @@ bool PeerManager::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgP
// this maintains the order of responses
// and prevents vRecvGetData to grow unbounded
if (!pfrom->vRecvGetData.empty()) return true;
- if (!peer->m_orphan_work_set.empty()) return true;
+ {
+ LOCK(g_cs_orphans);
+ if (!peer->m_orphan_work_set.empty()) return true;
+ }
// Don't bother if send buffer is too full to respond anyway
if (pfrom->fPauseSend)