diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-04-09 17:08:35 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-04-09 17:08:35 -0700 |
commit | 8fb442d81ae54f1c636c1a8c25528fb17ac04ed6 (patch) | |
tree | 84a796331ce0634fa7e65da15a7d3681e81377e9 /node/Node.cpp | |
parent | 73153b89b4270a6cc99aea47fb4019d660116e84 (diff) | |
download | infinitytier-8fb442d81ae54f1c636c1a8c25528fb17ac04ed6.tar.gz infinitytier-8fb442d81ae54f1c636c1a8c25528fb17ac04ed6.zip |
Yet more cleanup to TCP logic, this time adding a master switch and adding UDP preference in send().
Diffstat (limited to 'node/Node.cpp')
-rw-r--r-- | node/Node.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/node/Node.cpp b/node/Node.cpp index 2ae61136..26c1d90b 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -591,13 +591,29 @@ Node::ReasonForTermination Node::run() LOG("resynchronize forced by user, syncing with network"); } - if (resynchronize) + if (resynchronize) { + _r->tcpTunnelingEnabled = false; // turn off TCP tunneling master switch at first _r->timeOfLastResynchronize = now; + } - /* Ping supernodes separately, and do so more aggressively if we haven't - * heard anything from anyone since our last resynchronize / startup. */ + /* Supernodes are pinged separately and more aggressively. The + * ZT_STARTUP_AGGRO parameter sets a limit on how rapidly they are + * tried, while PingSupernodesThatNeedPing contains the logic for + * determining if they need PING. */ if ((now - lastSupernodePingCheck) >= ZT_STARTUP_AGGRO) { lastSupernodePingCheck = now; + + uint64_t lastReceiveFromAnySupernode = 0; // function object result paramter + _r->topology->eachSupernodePeer(Topology::FindMostRecentDirectReceiveTimestamp(lastReceiveFromAnySupernode)); + + // Turn on TCP tunneling master switch if we haven't heard anything since before + // the last resynchronize and we've been trying long enough. + uint64_t tlr = _r->timeOfLastResynchronize; + if ((lastReceiveFromAnySupernode < tlr)&&((now - tlr) >= ZT_TCP_TUNNEL_FAILOVER_TIMEOUT)) { + TRACE("network still unreachable after %u ms, TCP TUNNELING ENABLED",(unsigned int)ZT_TCP_TUNNEL_FAILOVER_TIMEOUT); + _r->tcpTunnelingEnabled = true; + } + _r->topology->eachSupernodePeer(Topology::PingSupernodesThatNeedPing(_r,now)); } |