Browse Source

when selecting tunnels if we can't find a low latency tunnel fall back to regular selection algorithm

pull/709/head
Jeff Becker 8 years ago
parent
commit
7fef5f5654
  1. 16
      TunnelPool.cpp

16
TunnelPool.cpp

@ -147,18 +147,26 @@ 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()) if (HasLatencyRequriement())
return GetLowestLatencyOutboundTunnel(excluded); tun = GetLowestLatencyOutboundTunnel(excluded);
if (! tun) {
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex); std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
return GetNextTunnel (m_OutboundTunnels, excluded); 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;
if (HasLatencyRequriement()) if (HasLatencyRequriement())
return GetLowestLatencyInboundTunnel(excluded); tun = GetLowestLatencyInboundTunnel(excluded);
if (! tun) {
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex); std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
return GetNextTunnel (m_InboundTunnels, excluded); tun = GetNextTunnel (m_InboundTunnels, excluded);
}
return tun;
} }
template<class TTunnels> template<class TTunnels>

Loading…
Cancel
Save