summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-04-09 12:10:05 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-04-09 12:10:05 -0700
commita8c12369fd921fbe46290e3dfe792e69e1ee3e47 (patch)
tree8e1991f78dc3309ad3a8487e67bc8275207b8440 /node
parent28a6d328a55d90ee21f5fa03e5aae447de7f1268 (diff)
downloadinfinitytier-a8c12369fd921fbe46290e3dfe792e69e1ee3e47.tar.gz
infinitytier-a8c12369fd921fbe46290e3dfe792e69e1ee3e47.zip
More tweaks to TCP logic for GitHub issue #60
Diffstat (limited to 'node')
-rw-r--r--node/Peer.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp
index c5c765de..99ef7ce3 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -170,12 +170,12 @@ bool Peer::sendPing(const RuntimeEnvironment *_r,uint64_t now)
bool sent = false;
SharedPtr<Peer> self(this);
Mutex::Lock _l(_lock);
- bool useTcp = _isTcpFailoverTime(_r,now);
+ bool useTcpOut = _isTcpFailoverTime(_r,now);
- TRACE("PING %s (useTcp==%d)",_id.address().toString().c_str(),(int)useTcp);
+ TRACE("PING %s (useTcpOut==%d)",_id.address().toString().c_str(),(int)useTcpOut);
for(std::vector<Path>::iterator p(_paths.begin());p!=_paths.end();++p) {
- if ((useTcp)||(!p->tcp())) {
+ if ((useTcpOut)||(p->type() != Path::PATH_TYPE_TCP_OUT)) {
p->pinged(now); // we log pings sent even if the send "fails", since what we want to track is when we last tried to ping
if (_r->sw->sendHELLO(self,*p)) {
p->sent(now);
@@ -210,15 +210,17 @@ bool Peer::_isTcpFailoverTime(const RuntimeEnvironment *_r,uint64_t now) const
uint64_t lastUdpPingSent = 0;
uint64_t lastUdpReceive = 0;
+ bool haveUdp = false;
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());
+ haveUdp = true;
}
}
- return ( (lastUdpPingSent > lastResync) && ((now - lastUdpReceive) >= ZT_TCP_TUNNEL_FAILOVER_TIMEOUT) );
+ return ( (!haveUdp) || ( (lastUdpPingSent > lastResync) && ((now - lastUdpReceive) >= ZT_TCP_TUNNEL_FAILOVER_TIMEOUT) ) );
}
return false;
}