|
|
|
@ -299,8 +299,21 @@ namespace tunnel
@@ -299,8 +299,21 @@ namespace tunnel
|
|
|
|
|
{ |
|
|
|
|
if (pool) |
|
|
|
|
{ |
|
|
|
|
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 (); |
|
|
|
|
pool->SetDeleted (); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -536,21 +549,13 @@ namespace tunnel
@@ -536,21 +549,13 @@ 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
@@ -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
@@ -590,7 +597,12 @@ namespace tunnel
|
|
|
|
|
CreateTunnel<OutboundTunnel> (newTunnel->GetTunnelConfig ()->Invert (), GetNextOutboundTunnel ()); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (pool->IsActive ()) |
|
|
|
|
pool->TunnelCreated (newTunnel); |
|
|
|
|
else |
|
|
|
|
newTunnel->SetTunnelPool (nullptr); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|