Skip to content

Commit

Permalink
Execute shutdown on port mapping thread
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Aug 3, 2024
1 parent 3dd9d41 commit eedb4f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nano/node/portmapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<nano::mutex> guard_l (mutex);
for (auto & protocol : protocols | boost::adaptors::filtered ([] (auto const & p) { return p.enabled; }))
Expand Down Expand Up @@ -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 ();
}

/*
Expand Down
2 changes: 2 additions & 0 deletions nano/node/portmapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eedb4f8

Please sign in to comment.