From d28c388f8892da2b459550a46a87a2756c7d4e73 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 15 Dec 2017 10:28:15 +0000 Subject: p2p: stop net server before closing starting connections This fixes a hang on exit due to race where a connection adds itself to the server after the starting connections are closed, but before the net server marks itself as stopped. --- src/p2p/net_node.inl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/p2p/net_node.inl') diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index f64b29c1f..90a6d4332 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -686,6 +686,10 @@ namespace nodetool template bool node_server::send_stop_signal() { + MDEBUG("[node] sending stop signal"); + m_net_server.send_stop_signal(); + MDEBUG("[node] Stop signal sent"); + std::list connection_ids; m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt) { connection_ids.push_back(cntxt.m_connection_id); @@ -695,8 +699,7 @@ namespace nodetool m_net_server.get_config_object().close(connection_id); m_payload_handler.stop(); - m_net_server.send_stop_signal(); - MDEBUG("[node] Stop signal sent"); + return true; } //----------------------------------------------------------------------------------- -- cgit v1.2.3