From f79821ac7ebc269b18dd2edd8ac0cb022861ad11 Mon Sep 17 00:00:00 2001 From: rfree2monero Date: Tue, 24 Feb 2015 21:02:48 +0100 Subject: fix locking in count-peers thread (2) --- src/p2p/net_node.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/p2p/net_node.h') diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index 5417ffa52..5b034ce25 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -89,6 +89,7 @@ namespace nodetool { m_current_number_of_out_peers = 0; m_save_graph = false; + is_closing = false; } static void init_options(boost::program_options::options_description& desc); @@ -209,6 +210,13 @@ namespace nodetool bool set_rate_down_limit(const boost::program_options::variables_map& vm, int64_t limit); bool set_rate_limit(const boost::program_options::variables_map& vm, uint64_t limit); + void kill() { ///< will be called e.g. from deinit() + _info("Killing the net_node"); + is_closing = true; + mPeersLoggerThread->join(); // make sure the thread finishes + _info("Joined extra background net_node threads"); + } + //debug functions std::string print_connections_container(); @@ -247,7 +255,8 @@ namespace nodetool bool m_hide_my_port; bool m_no_igd; std::atomic m_save_graph; - + std::atomic is_closing; + std::unique_ptr mPeersLoggerThread; //critical_section m_connections_lock; //connections_indexed_container m_connections; -- cgit v1.2.3