More tweaks to TCP failover logic. Such edge case.

This commit is contained in:
Adam Ierymenko 2014-04-02 17:32:47 -04:00
parent 700a450806
commit 81e5690410
3 changed files with 31 additions and 22 deletions

View file

@ -267,27 +267,8 @@ public:
* @param now Current time
* @return True if it's time to attempt TCP failover (if we have TCP_OUT paths)
*/
inline bool isTcpFailoverTime(const RuntimeEnvironment *_r,uint64_t now) const
throw()
{
if ((now - _r->timeOfLastResynchronize) >= ZT_TCP_TUNNEL_FAILOVER_TIMEOUT) {
uint64_t lastUdpPingSent = 0;
uint64_t lastUdpReceive = 0;
{
Mutex::Lock _l(_lock);
for(std::vector<Path>::const_iterator p(_paths.begin());p!=_paths.end();++p) {
if (p->type() == Path::PATH_TYPE_UDP) {
lastUdpPingSent = std::max(lastUdpPingSent,p->lastPing());
lastUdpReceive = std::max(lastUdpReceive,p->lastReceived());
}
}
}
return ( (lastUdpPingSent > lastUdpReceive) && ((now - lastUdpPingSent) >= ZT_TCP_TUNNEL_FAILOVER_TIMEOUT) );
}
return false;
}
bool isTcpFailoverTime(const RuntimeEnvironment *_r,uint64_t now) const
throw();
/**
* @return Current latency or 0 if unknown (max: 65535)