mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-19 01:09:58 +00:00
don't compare OBEP hash twice to check if it's a fresh tunnel
This commit is contained in:
parent
04bccedd9b
commit
9a30068ae5
@ -927,9 +927,7 @@ namespace stream
|
|||||||
else if (!m_CurrentOutboundTunnel->IsEstablished ())
|
else if (!m_CurrentOutboundTunnel->IsEstablished ())
|
||||||
{
|
{
|
||||||
auto oldOutboundTunnel = m_CurrentOutboundTunnel;
|
auto oldOutboundTunnel = m_CurrentOutboundTunnel;
|
||||||
m_CurrentOutboundTunnel = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNewOutboundTunnel (m_CurrentOutboundTunnel);
|
std::tie(m_CurrentOutboundTunnel, freshTunnel) = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNewOutboundTunnel (m_CurrentOutboundTunnel);
|
||||||
if (m_CurrentOutboundTunnel && oldOutboundTunnel->GetEndpointIdentHash() != m_CurrentOutboundTunnel->GetEndpointIdentHash())
|
|
||||||
freshTunnel = true;
|
|
||||||
}
|
}
|
||||||
if (!m_CurrentOutboundTunnel)
|
if (!m_CurrentOutboundTunnel)
|
||||||
{
|
{
|
||||||
|
@ -263,10 +263,11 @@ namespace tunnel
|
|||||||
return tunnel;
|
return tunnel;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<OutboundTunnel> TunnelPool::GetNewOutboundTunnel (std::shared_ptr<OutboundTunnel> old) const
|
std::pair<std::shared_ptr<OutboundTunnel>, bool> TunnelPool::GetNewOutboundTunnel (std::shared_ptr<OutboundTunnel> old) const
|
||||||
{
|
{
|
||||||
if (old && old->IsEstablished ()) return old;
|
if (old && old->IsEstablished ()) return std::make_pair(old, false);
|
||||||
std::shared_ptr<OutboundTunnel> tunnel;
|
std::shared_ptr<OutboundTunnel> tunnel;
|
||||||
|
bool freshTunnel = false;
|
||||||
if (old)
|
if (old)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
|
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
|
||||||
@ -279,8 +280,11 @@ namespace tunnel
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!tunnel)
|
if (!tunnel)
|
||||||
|
{
|
||||||
tunnel = GetNextOutboundTunnel ();
|
tunnel = GetNextOutboundTunnel ();
|
||||||
return tunnel;
|
freshTunnel = true;
|
||||||
|
}
|
||||||
|
return std::make_pair(tunnel, freshTunnel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TunnelPool::CreateTunnels ()
|
void TunnelPool::CreateTunnels ()
|
||||||
|
@ -81,7 +81,7 @@ namespace tunnel
|
|||||||
i2p::data::RouterInfo::CompatibleTransports compatible = i2p::data::RouterInfo::eAllTransports) const;
|
i2p::data::RouterInfo::CompatibleTransports compatible = i2p::data::RouterInfo::eAllTransports) const;
|
||||||
std::shared_ptr<InboundTunnel> GetNextInboundTunnel (std::shared_ptr<InboundTunnel> excluded = nullptr,
|
std::shared_ptr<InboundTunnel> GetNextInboundTunnel (std::shared_ptr<InboundTunnel> excluded = nullptr,
|
||||||
i2p::data::RouterInfo::CompatibleTransports compatible = i2p::data::RouterInfo::eAllTransports) const;
|
i2p::data::RouterInfo::CompatibleTransports compatible = i2p::data::RouterInfo::eAllTransports) const;
|
||||||
std::shared_ptr<OutboundTunnel> GetNewOutboundTunnel (std::shared_ptr<OutboundTunnel> old) const;
|
std::pair<std::shared_ptr<OutboundTunnel>, bool> GetNewOutboundTunnel (std::shared_ptr<OutboundTunnel> old) const;
|
||||||
void ManageTunnels (uint64_t ts);
|
void ManageTunnels (uint64_t ts);
|
||||||
void ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg);
|
void ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg);
|
||||||
void ProcessDeliveryStatus (std::shared_ptr<I2NPMessage> msg);
|
void ProcessDeliveryStatus (std::shared_ptr<I2NPMessage> msg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user