mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-09-04 14:54:40 +00:00
give each udp server tunnel its own cleanup timer
This commit is contained in:
@@ -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 ();)
|
||||
|
||||
Reference in New Issue
Block a user