mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-08 22:57:52 +00:00
select tunnels correctly
This commit is contained in:
parent
7fef5f5654
commit
5425e9aee3
@ -147,26 +147,14 @@ namespace tunnel
|
|||||||
|
|
||||||
std::shared_ptr<OutboundTunnel> TunnelPool::GetNextOutboundTunnel (std::shared_ptr<OutboundTunnel> excluded) const
|
std::shared_ptr<OutboundTunnel> TunnelPool::GetNextOutboundTunnel (std::shared_ptr<OutboundTunnel> excluded) const
|
||||||
{
|
{
|
||||||
std::shared_ptr<OutboundTunnel> tun = nullptr;
|
|
||||||
if (HasLatencyRequriement())
|
|
||||||
tun = GetLowestLatencyOutboundTunnel(excluded);
|
|
||||||
if (! tun) {
|
|
||||||
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
|
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
|
||||||
tun = GetNextTunnel (m_OutboundTunnels, excluded);
|
return GetNextTunnel (m_OutboundTunnels, excluded);
|
||||||
}
|
|
||||||
return tun;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<InboundTunnel> TunnelPool::GetNextInboundTunnel (std::shared_ptr<InboundTunnel> excluded) const
|
std::shared_ptr<InboundTunnel> TunnelPool::GetNextInboundTunnel (std::shared_ptr<InboundTunnel> excluded) const
|
||||||
{
|
{
|
||||||
std::shared_ptr<InboundTunnel> tun = nullptr;
|
|
||||||
if (HasLatencyRequriement())
|
|
||||||
tun = GetLowestLatencyInboundTunnel(excluded);
|
|
||||||
if (! tun) {
|
|
||||||
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
|
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
|
||||||
tun = GetNextTunnel (m_InboundTunnels, excluded);
|
return GetNextTunnel (m_InboundTunnels, excluded);
|
||||||
}
|
|
||||||
return tun;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TTunnels>
|
template<class TTunnels>
|
||||||
@ -179,6 +167,10 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
if (it->IsEstablished () && it != excluded)
|
if (it->IsEstablished () && it != excluded)
|
||||||
{
|
{
|
||||||
|
if(HasLatencyRequirement() && !it->LatencyFitsRange(m_MinLatency, m_MaxLatency)) {
|
||||||
|
i ++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
tunnel = it;
|
tunnel = it;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user