give each udp server tunnel its own cleanup timer

This commit is contained in:
PobreGato
2026-08-23 02:32:29 +03:00
parent f9b1666305
commit 53da7ae2f5
4 changed files with 28 additions and 37 deletions
-34
View File
@@ -117,13 +117,6 @@ namespace client
m_AddressBook.StartResolvers ();
// start UDP cleanup
if (!m_ServerForwards.empty ())
{
m_CleanupUDPTimer.reset (new boost::asio::steady_timer(m_SharedLocalDestination->GetService ()));
ScheduleCleanupUDP();
}
// start torrents RPC server
for (auto& it: m_TorrentsRPCServers)
it.second->Start ();
@@ -220,13 +213,6 @@ namespace client
m_ClientForwards.clear();
}
LogPrint(eLogInfo, "Clients: Stopping UDP Tunnels timers");
if (m_CleanupUDPTimer)
{
m_CleanupUDPTimer->cancel ();
m_CleanupUDPTimer = nullptr;
}
{
LogPrint(eLogInfo, "Clients: Stopping Destinations");
std::lock_guard<std::mutex> lock(m_DestinationsMutex);
@@ -1182,26 +1168,6 @@ namespace client
}
}
void ClientContext::ScheduleCleanupUDP()
{
if (m_CleanupUDPTimer)
{
// schedule cleanup in 17 seconds
m_CleanupUDPTimer->expires_after (std::chrono::seconds (17));
m_CleanupUDPTimer->async_wait(std::bind(&ClientContext::CleanupUDP, this, std::placeholders::_1));
}
}
void ClientContext::CleanupUDP(const boost::system::error_code & ecode)
{
if(!ecode)
{
std::lock_guard<std::mutex> lock(m_ForwardsMutex);
for (auto & s : m_ServerForwards ) s.second->ExpireStale();
ScheduleCleanupUDP();
}
}
void ClientContext::VisitTunnels (bool clean)
{
for (auto it = m_ClientTunnels.begin (); it != m_ClientTunnels.end ();)