Browse Source

Fix network-snapshot method when there's a lot of node activity (dereferencing shared pointer from weak ptr without verifying weak ptr).

cl-refactor
subtly 10 years ago
parent
commit
d651501be0
  1. 6
      libp2p/NodeTable.cpp

6
libp2p/NodeTable.cpp

@ -138,8 +138,10 @@ list<NodeEntry> NodeTable::snapshot() const
list<NodeEntry> ret; list<NodeEntry> ret;
Guard l(x_state); Guard l(x_state);
for (auto s: m_state) for (auto s: m_state)
for (auto n: s.nodes) for (auto np: s.nodes)
ret.push_back(*n.lock()); if (auto n = np.lock())
if (!!n)
ret.push_back(*n);
return move(ret); return move(ret);
} }

Loading…
Cancel
Save