|
|
@ -243,6 +243,7 @@ namespace tunnel |
|
|
|
|
|
|
|
|
|
|
|
Tunnel * Tunnels::GetPendingTunnel (uint32_t replyMsgID) |
|
|
|
Tunnel * Tunnels::GetPendingTunnel (uint32_t replyMsgID) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
std::unique_lock<std::mutex> l(m_PendingTunnelsMutex); |
|
|
|
auto it = m_PendingTunnels.find(replyMsgID); |
|
|
|
auto it = m_PendingTunnels.find(replyMsgID); |
|
|
|
if (it != m_PendingTunnels.end () && it->second->GetState () == eTunnelStatePending) |
|
|
|
if (it != m_PendingTunnels.end () && it->second->GetState () == eTunnelStatePending) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -299,6 +300,11 @@ namespace tunnel |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (pool) |
|
|
|
if (pool) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::unique_lock<std::mutex> l(m_PendingTunnelsMutex); |
|
|
|
|
|
|
|
for (auto it: m_PendingTunnels) |
|
|
|
|
|
|
|
if (it.second->GetTunnelPool () == pool) it.second->SetTunnelPool (nullptr); |
|
|
|
|
|
|
|
} |
|
|
|
std::unique_lock<std::mutex> l(m_PoolsMutex); |
|
|
|
std::unique_lock<std::mutex> l(m_PoolsMutex); |
|
|
|
m_Pools.erase (pool->GetIdentHash ()); |
|
|
|
m_Pools.erase (pool->GetIdentHash ()); |
|
|
|
delete pool; |
|
|
|
delete pool; |
|
|
@ -374,9 +380,19 @@ namespace tunnel |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Tunnels::ManageTunnels () |
|
|
|
void Tunnels::ManageTunnels () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ManagePendingTunnels (); |
|
|
|
|
|
|
|
ManageInboundTunnels (); |
|
|
|
|
|
|
|
ManageOutboundTunnels (); |
|
|
|
|
|
|
|
ManageTransitTunnels (); |
|
|
|
|
|
|
|
ManageTunnelPools (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Tunnels::ManagePendingTunnels () |
|
|
|
{ |
|
|
|
{ |
|
|
|
// check pending tunnel. delete failed or timeout
|
|
|
|
// check pending tunnel. delete failed or timeout
|
|
|
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
|
|
|
|
std::unique_lock<std::mutex> l(m_PendingTunnelsMutex); |
|
|
|
for (auto it = m_PendingTunnels.begin (); it != m_PendingTunnels.end ();) |
|
|
|
for (auto it = m_PendingTunnels.begin (); it != m_PendingTunnels.end ();) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto tunnel = it->second; |
|
|
|
auto tunnel = it->second; |
|
|
@ -405,11 +421,6 @@ namespace tunnel |
|
|
|
it = m_PendingTunnels.erase (it); |
|
|
|
it = m_PendingTunnels.erase (it); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ManageInboundTunnels (); |
|
|
|
|
|
|
|
ManageOutboundTunnels (); |
|
|
|
|
|
|
|
ManageTransitTunnels (); |
|
|
|
|
|
|
|
ManageTunnelPools (); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Tunnels::ManageOutboundTunnels () |
|
|
|
void Tunnels::ManageOutboundTunnels () |
|
|
|