aboutsummaryrefslogtreecommitdiff
path: root/src/p2p/net_node.inl
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-07-29 10:03:37 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-07-29 10:04:36 +0100
commit04ebfbfefa1ae27a3d92d9f78548ca595687fe01 (patch)
tree2921d395f6cdfa6d632a43c4fe0aa9c29a246bda /src/p2p/net_node.inl
parentp2p: fix thread leak (diff)
downloadmonero-04ebfbfefa1ae27a3d92d9f78548ca595687fe01.tar.xz
p2p: close connections when exiting
This ensures they don't leak if they were in the middle of an async operation.
Diffstat (limited to '')
-rw-r--r--src/p2p/net_node.inl8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 4ecf8f710..5bc9cd48f 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -714,6 +714,14 @@ namespace nodetool
template<class t_payload_net_handler>
bool node_server<t_payload_net_handler>::send_stop_signal()
{
+ std::list<boost::uuids::uuid> connection_ids;
+ m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt) {
+ connection_ids.push_back(cntxt.m_connection_id);
+ return true;
+ });
+ for (const auto &connection_id: connection_ids)
+ m_net_server.get_config_object().close(connection_id);
+
m_payload_handler.stop();
m_net_server.send_stop_signal();
MDEBUG("[node] Stop signal sent");