From 2996033df0cf370c4987b346a9c455db04a38cb1 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Mon, 10 Aug 2015 20:37:56 +0200 Subject: [PATCH] bugfix: error code 995 --- libp2p/Common.h | 4 +++- libp2p/NodeTable.cpp | 24 ++++++++++++------------ libp2p/NodeTable.h | 3 --- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/libp2p/Common.h b/libp2p/Common.h index 1b65d4759..5d4b136ff 100644 --- a/libp2p/Common.h +++ b/libp2p/Common.h @@ -221,7 +221,7 @@ class DeadlineOps { public: DeadlineOp(ba::io_service& _io, unsigned _msInFuture, std::function const& _f): m_timer(new ba::deadline_timer(_io)) { m_timer->expires_from_now(boost::posix_time::milliseconds(_msInFuture)); m_timer->async_wait(_f); } - ~DeadlineOp() {} + ~DeadlineOp() { if (m_timer) m_timer->cancel(); } DeadlineOp(DeadlineOp&& _s): m_timer(_s.m_timer.release()) {} DeadlineOp& operator=(DeadlineOp&& _s) { m_timer.reset(_s.m_timer.release()); return *this; } @@ -241,6 +241,8 @@ public: void schedule(unsigned _msInFuture, std::function const& _f) { if (m_stopped) return; DEV_GUARDED(x_timers) m_timers.emplace_back(m_io, _msInFuture, _f); } void stop() { m_stopped = true; DEV_GUARDED(x_timers) m_timers.clear(); } + + bool isStopped() const { return m_stopped; } protected: void reap(); diff --git a/libp2p/NodeTable.cpp b/libp2p/NodeTable.cpp index 19c86cc0f..94803f3f0 100644 --- a/libp2p/NodeTable.cpp +++ b/libp2p/NodeTable.cpp @@ -46,7 +46,6 @@ NodeTable::NodeTable(ba::io_service& _io, KeyPair const& _alias, NodeIPEndpoint m_socket(new NodeSocket(_io, *this, (bi::udp::endpoint)m_node.endpoint)), m_socketPointer(m_socket.get()), m_timers(_io) - ,m_debug_destroyed(false) { for (unsigned i = 0; i < s_bins; i++) m_state[i].distance = i; @@ -68,12 +67,8 @@ NodeTable::NodeTable(ba::io_service& _io, KeyPair const& _alias, NodeIPEndpoint NodeTable::~NodeTable() { - DEV_GUARDED(x_debug) - { - m_debug_destroyed = true; - m_timers.stop(); - m_socketPointer->disconnect(); - } + m_socketPointer->disconnect(); + m_timers.stop(); } void NodeTable::processEvents() @@ -204,12 +199,17 @@ void NodeTable::doDiscover(NodeId _node, unsigned _round, shared_ptr