diff --git a/Tunnel.cpp b/Tunnel.cpp index 7bfec218..e1f5c035 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -36,10 +36,13 @@ namespace tunnel TunnelLatency::Latency TunnelLatency::GetMeanLatency() const { std::unique_lock lock(m_access); - Latency l = 0; - for(auto s : m_samples) - l += s; - return l / m_samples.size(); + if (m_samples.size() > 0) { + Latency l = 0; + for(auto s : m_samples) + l += s; + return l / m_samples.size(); + } + return 0; } diff --git a/TunnelPool.cpp b/TunnelPool.cpp index 0c3db211..ccd4c12c 100644 --- a/TunnelPool.cpp +++ b/TunnelPool.cpp @@ -167,7 +167,7 @@ namespace tunnel { if (it->IsEstablished () && it != excluded) { - if(HasLatencyRequirement() && !it->LatencyFitsRange(m_MinLatency, m_MaxLatency)) { + if(HasLatencyRequirement() && it->LatencyIsKnown() && !it->LatencyFitsRange(m_MinLatency, m_MaxLatency)) { i ++; continue; }