resuse instance of local destination upon restart

This commit is contained in:
orignal 2014-10-13 11:21:57 -04:00
parent eff0e13f31
commit a0f43d9772
7 changed files with 50 additions and 29 deletions

View file

@ -12,7 +12,7 @@ namespace tunnel
{
TunnelPool::TunnelPool (i2p::garlic::GarlicDestination& localDestination, int numHops, int numTunnels):
m_LocalDestination (localDestination), m_NumHops (numHops), m_NumTunnels (numTunnels),
m_IsDeleted (false)
m_IsActive (true)
{
}
@ -27,17 +27,20 @@ namespace tunnel
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
for (auto it: m_InboundTunnels)
it->SetTunnelPool (nullptr);
m_InboundTunnels.clear ();
}
{
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
for (auto it: m_OutboundTunnels)
it->SetTunnelPool (nullptr);
m_OutboundTunnels.clear ();
}
m_Tests.clear ();
}
void TunnelPool::TunnelCreated (InboundTunnel * createdTunnel)
{
if (m_IsDeleted) return;
if (!m_IsActive) return;
{
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
m_InboundTunnels.insert (createdTunnel);
@ -61,7 +64,7 @@ namespace tunnel
void TunnelPool::TunnelCreated (OutboundTunnel * createdTunnel)
{
if (m_IsDeleted) return;
if (!m_IsActive) return;
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
m_OutboundTunnels.insert (createdTunnel);
}