don't include old tunnel to LeaseSet if recreated

This commit is contained in:
orignal 2021-09-10 19:57:38 -04:00
parent ad036de69d
commit 5e2e1a1e3d
3 changed files with 19 additions and 6 deletions

View file

@ -113,6 +113,17 @@ namespace tunnel
if (!m_IsActive) return;
{
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
if (createdTunnel->IsRecreated ())
{
// find and mark old tunnel as expired
createdTunnel->SetRecreated (false);
for (auto& it: m_InboundTunnels)
if (it->IsRecreated () && it->GetNextIdentHash () == createdTunnel->GetNextIdentHash ())
{
it->SetState (eTunnelStateExpiring);
break;
}
}
m_InboundTunnels.insert (createdTunnel);
}
if (m_LocalDestination)
@ -577,6 +588,8 @@ namespace tunnel
auto newTunnel = tunnels.CreateInboundTunnel (config, shared_from_this(), outboundTunnel);
if (newTunnel->IsEstablished ()) // zero hops
TunnelCreated (newTunnel);
else
newTunnel->SetRecreated (true);
}
}