don't blow up

This commit is contained in:
Jeff Becker 2016-11-15 11:31:15 -05:00
parent 0c5ca28a14
commit 76c9b66db4
2 changed files with 8 additions and 5 deletions

View File

@ -36,11 +36,14 @@ namespace tunnel
TunnelLatency::Latency TunnelLatency::GetMeanLatency() const
{
std::unique_lock<std::mutex> lock(m_access);
if (m_samples.size() > 0) {
Latency l = 0;
for(auto s : m_samples)
l += s;
return l / m_samples.size();
}
return 0;
}
Tunnel::Tunnel (std::shared_ptr<const TunnelConfig> config):

View File

@ -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;
}