mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
resuse instance of local destination upon restart
This commit is contained in:
parent
eff0e13f31
commit
a0f43d9772
7 changed files with 50 additions and 29 deletions
44
Tunnel.cpp
44
Tunnel.cpp
|
@ -299,11 +299,24 @@ namespace tunnel
|
|||
{
|
||||
if (pool)
|
||||
{
|
||||
pool->DetachTunnels ();
|
||||
pool->SetDeleted ();
|
||||
StopTunnelPool (pool);
|
||||
m_Pools.erase (pool->GetLocalDestination ().GetIdentHash ());
|
||||
for (auto it: m_PendingTunnels)
|
||||
if (it.second->GetTunnelPool () == pool)
|
||||
it.second->SetTunnelPool (nullptr);
|
||||
delete pool;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Tunnels::StopTunnelPool (TunnelPool * pool)
|
||||
{
|
||||
if (pool)
|
||||
{
|
||||
pool->SetActive (false);
|
||||
pool->DetachTunnels ();
|
||||
}
|
||||
}
|
||||
|
||||
void Tunnels::AddTransitTunnel (TransitTunnel * tunnel)
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_TransitTunnelsMutex);
|
||||
|
@ -536,22 +549,14 @@ namespace tunnel
|
|||
void Tunnels::ManageTunnelPools ()
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_PoolsMutex);
|
||||
for (auto it = m_Pools.begin (); it != m_Pools.end ();)
|
||||
for (auto it: m_Pools)
|
||||
{
|
||||
TunnelPool * pool = it->second;
|
||||
if (!pool->IsDeleted ())
|
||||
TunnelPool * pool = it.second;
|
||||
if (pool->IsActive ())
|
||||
{
|
||||
pool->CreateTunnels ();
|
||||
pool->TestTunnels ();
|
||||
it++;
|
||||
}
|
||||
else
|
||||
{
|
||||
it = m_Pools.erase (it);
|
||||
for (auto it1: m_PendingTunnels)
|
||||
if (it1.second->GetTunnelPool () == pool) it1.second->SetTunnelPool (nullptr);
|
||||
delete pool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,8 +580,10 @@ namespace tunnel
|
|||
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
|
||||
m_OutboundTunnels.push_back (newTunnel);
|
||||
auto pool = newTunnel->GetTunnelPool ();
|
||||
if (pool)
|
||||
if (pool && pool->IsActive ())
|
||||
pool->TunnelCreated (newTunnel);
|
||||
else
|
||||
newTunnel->SetTunnelPool (nullptr);
|
||||
}
|
||||
|
||||
void Tunnels::AddInboundTunnel (InboundTunnel * newTunnel)
|
||||
|
@ -590,7 +597,12 @@ namespace tunnel
|
|||
CreateTunnel<OutboundTunnel> (newTunnel->GetTunnelConfig ()->Invert (), GetNextOutboundTunnel ());
|
||||
}
|
||||
else
|
||||
pool->TunnelCreated (newTunnel);
|
||||
{
|
||||
if (pool->IsActive ())
|
||||
pool->TunnelCreated (newTunnel);
|
||||
else
|
||||
newTunnel->SetTunnelPool (nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue