Browse Source

debug

cl-refactor
Vlad Gluhovsky 10 years ago
parent
commit
e000d36b3c
  1. 15
      libp2p/NodeTable.cpp
  2. 3
      libp2p/NodeTable.h

15
libp2p/NodeTable.cpp

@ -46,6 +46,7 @@ NodeTable::NodeTable(ba::io_service& _io, KeyPair const& _alias, NodeIPEndpoint
m_socket(new NodeSocket(_io, *this, (bi::udp::endpoint)m_node.endpoint)), m_socket(new NodeSocket(_io, *this, (bi::udp::endpoint)m_node.endpoint)),
m_socketPointer(m_socket.get()), m_socketPointer(m_socket.get()),
m_timers(_io) m_timers(_io)
,m_debug_destroyed(false)
{ {
for (unsigned i = 0; i < s_bins; i++) for (unsigned i = 0; i < s_bins; i++)
m_state[i].distance = i; m_state[i].distance = i;
@ -67,8 +68,12 @@ NodeTable::NodeTable(ba::io_service& _io, KeyPair const& _alias, NodeIPEndpoint
NodeTable::~NodeTable() NodeTable::~NodeTable()
{ {
m_timers.stop(); DEV_GUARDED(x_debug)
m_socketPointer->disconnect(); {
m_debug_destroyed = true;
m_timers.stop();
m_socketPointer->disconnect();
}
} }
void NodeTable::processEvents() void NodeTable::processEvents()
@ -200,7 +205,11 @@ void NodeTable::doDiscover(NodeId _node, unsigned _round, shared_ptr<set<shared_
{ {
if (_ec) if (_ec)
clog(NodeTableWarn) << "Discovery timer canceled!"; clog(NodeTableWarn) << "Discovery timer canceled!";
doDiscover(_node, _round + 1, _tried);
if (!m_debug_destroyed)
DEV_GUARDED(x_debug)
if (!m_debug_destroyed)
doDiscover(_node, _round + 1, _tried);
}); });
} }

3
libp2p/NodeTable.h

@ -265,6 +265,9 @@ private:
NodeSocket* m_socketPointer; ///< Set to m_socket.get(). Socket is created in constructor and disconnected in destructor to ensure access to pointer is safe. NodeSocket* m_socketPointer; ///< Set to m_socket.get(). Socket is created in constructor and disconnected in destructor to ensure access to pointer is safe.
DeadlineOps m_timers; DeadlineOps m_timers;
Mutex x_debug;
bool m_debug_destroyed;
}; };
inline std::ostream& operator<<(std::ostream& _out, NodeTable const& _nodeTable) inline std::ostream& operator<<(std::ostream& _out, NodeTable const& _nodeTable)

Loading…
Cancel
Save