Browse Source

Merge pull request #1827 from subtly/netFix

Fix mutex when evicting node from node table.
cl-refactor
Gav Wood 10 years ago
parent
commit
1a84450e44
  1. 2
      libp2p/NodeTable.cpp
  2. 2
      libp2p/NodeTable.h

2
libp2p/NodeTable.cpp

@ -576,8 +576,8 @@ void NodeTable::doCheckEvictions(boost::system::error_code const& _ec)
bool evictionsRemain = false; bool evictionsRemain = false;
list<shared_ptr<NodeEntry>> drop; list<shared_ptr<NodeEntry>> drop;
{ {
Guard ln(x_nodes);
Guard le(x_evictions); Guard le(x_evictions);
Guard ln(x_nodes);
for (auto& e: m_evictions) for (auto& e: m_evictions)
if (chrono::steady_clock::now() - e.first.second > c_reqTimeout) if (chrono::steady_clock::now() - e.first.second > c_reqTimeout)
if (m_nodes.count(e.second)) if (m_nodes.count(e.second))

2
libp2p/NodeTable.h

@ -254,7 +254,7 @@ private:
mutable Mutex x_state; ///< LOCK x_state first if both x_nodes and x_state locks are required. mutable Mutex x_state; ///< LOCK x_state first if both x_nodes and x_state locks are required.
std::array<NodeBucket, s_bins> m_state; ///< State of p2p node network. std::array<NodeBucket, s_bins> m_state; ///< State of p2p node network.
Mutex x_evictions; ///< LOCK x_nodes first if both x_nodes and x_evictions locks are required. Mutex x_evictions; ///< LOCK x_evictions first if both x_nodes and x_evictions locks are required.
std::deque<EvictionTimeout> m_evictions; ///< Eviction timeouts. std::deque<EvictionTimeout> m_evictions; ///< Eviction timeouts.
Mutex x_pubkDiscoverPings; ///< LOCK x_nodes first if both x_nodes and x_pubkDiscoverPings locks are required. Mutex x_pubkDiscoverPings; ///< LOCK x_nodes first if both x_nodes and x_pubkDiscoverPings locks are required.

Loading…
Cancel
Save