Skip to content

Commit c6a93bd

Browse files
committed
quick hack for fRelayTxes race
1 parent df50d4f commit c6a93bd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/net.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -922,24 +922,24 @@ static bool CompareNodeTXTime(const NodeEvictionCandidate &a, const NodeEviction
922922
*/
923923
bool CConnman::AttemptToEvictConnection()
924924
{
925-
std::vector<NodeEvictionCandidate> vEvictionCandidates;
925+
std::vector<CNode*> vNodesCopy;
926926
{
927927
LOCK(cs_vNodes);
928-
929-
BOOST_FOREACH(CNode *node, vNodes) {
930-
if (node->fWhitelisted)
931-
continue;
932-
if (!node->fInbound)
933-
continue;
934-
if (node->fDisconnect)
935-
continue;
928+
vNodesCopy = vNodes;
929+
for(CNode* pnode : vNodes)
930+
pnode->AddRef();
931+
}
932+
std::vector<NodeEvictionCandidate> vEvictionCandidates;
933+
for(CNode* node : vNodesCopy) {
934+
if (!node->fWhitelisted && node->fInbound && node->fDisconnect) {
936935
LOCK(node->cs_filter);
937936
NodeEvictionCandidate candidate = {node->id, node->nTimeConnected, node->nMinPingUsecTime,
938937
node->nLastBlockTime, node->nLastTXTime,
939938
(node->nServices & nRelevantServices) == nRelevantServices,
940939
node->fRelayTxes, node->pfilter != NULL, node->addr, node->nKeyedNetGroup};
941940
vEvictionCandidates.push_back(candidate);
942941
}
942+
node->Release();
943943
}
944944

945945
if (vEvictionCandidates.empty()) return false;

0 commit comments

Comments
 (0)