From 5f3337b53d61e8f4860af9b9d419ba3ceb5a22e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Sat, 3 Aug 2024 13:54:56 +0200 Subject: [PATCH] Execute shutdown on port mapping thread --- nano/node/portmapping.cpp | 9 +++++++++ nano/node/portmapping.hpp | 2 ++ 2 files changed, 11 insertions(+) diff --git a/nano/node/portmapping.cpp b/nano/node/portmapping.cpp index b70b8edd9c..0dd1605bda 100644 --- a/nano/node/portmapping.cpp +++ b/nano/node/portmapping.cpp @@ -66,6 +66,11 @@ void nano::port_mapping::stop () { thread.join (); } +} + +void nano::port_mapping::shutdown () +{ + node.logger.debug (nano::log::type::upnp, "UPnP shutdown..."); nano::lock_guard guard_l (mutex); for (auto & protocol : protocols | boost::adaptors::filtered ([] (auto const & p) { return p.enabled; })) @@ -308,6 +313,10 @@ void nano::port_mapping::run () condition.wait_for (lock, node.network_params.portmapping.health_check_period, [this] { return stopped.load (); }); } + + lock.unlock (); + + shutdown (); } /* diff --git a/nano/node/portmapping.hpp b/nano/node/portmapping.hpp index 6e47dd1395..cc542896ad 100644 --- a/nano/node/portmapping.hpp +++ b/nano/node/portmapping.hpp @@ -56,12 +56,14 @@ class port_mapping private: void run (); + void shutdown (); /** Add port mappings for the node port (not RPC). Refresh when the lease ends. */ void refresh_mapping (); /** Check occasionally to refresh in case router loses mapping */ void check_mapping (); /** Returns false if mapping still exists */ bool check_lost_or_old_mapping (); + std::string get_config_port (std::string const &); private: // Dependencies