Browse Source

select tunnels correctly

pull/709/head
Jeff Becker 8 years ago
parent
commit
5425e9aee3
  1. 24
      TunnelPool.cpp

24
TunnelPool.cpp

@ -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; std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
if (HasLatencyRequriement()) return GetNextTunnel (m_OutboundTunnels, excluded);
tun = GetLowestLatencyOutboundTunnel(excluded);
if (! tun) {
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
tun = 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; std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
if (HasLatencyRequriement()) return GetNextTunnel (m_InboundTunnels, excluded);
tun = GetLowestLatencyInboundTunnel(excluded);
if (! tun) {
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
tun = 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…
Cancel
Save