diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-04-17 09:14:21 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-04-17 09:14:21 -0700 |
commit | 2487a8bede10f1ea58ca2778d9772ee9056e6b12 (patch) | |
tree | 7787990059acc047506bdbd9943c2fce06bc0d10 /node | |
parent | f1c0563c40dc9e3ec5e975d3e1e8d6057ed6bd83 (diff) | |
download | infinitytier-2487a8bede10f1ea58ca2778d9772ee9056e6b12.tar.gz infinitytier-2487a8bede10f1ea58ca2778d9772ee9056e6b12.zip |
Fix for 100% cpu issue.
Diffstat (limited to 'node')
-rw-r--r-- | node/Peer.cpp | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp index 7ffe8926..827dc7de 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -166,33 +166,31 @@ void Peer::received( } if ( (!pathAlreadyKnown) && (RR->node->shouldUsePathForZeroTierTraffic(tPtr,_id.address(),path->localAddress(),path->address())) ) { - if (verb == Packet::VERB_OK) { - Mutex::Lock _l(_paths_m); - if (path->address().ss_family == AF_INET) { - if ( (!_v4Path.p) || (!_v4Path.p->alive(now)) || ((_v4Path.p->address() != _v4ClusterPreferred)&&(path->preferenceRank() >= _v4Path.p->preferenceRank())) ) { - _v4Path.lr = now; - _v4Path.p = path; -#ifdef ZT_ENABLE_CLUSTER - _v4Path.localClusterSuboptimal = isClusterSuboptimalPath; - if (RR->cluster) - RR->cluster->broadcastHavePeer(_id); -#endif - } - } else if (path->address().ss_family == AF_INET6) { - if ( (!_v6Path.p) || (!_v6Path.p->alive(now)) || ((_v6Path.p->address() != _v6ClusterPreferred)&&(path->preferenceRank() >= _v6Path.p->preferenceRank())) ) { - _v6Path.lr = now; - _v6Path.p = path; + Mutex::Lock _l(_paths_m); + _PeerPath *potentialNewPeerPath = (_PeerPath *)0; + if (path->address().ss_family == AF_INET) { + if ( (!_v4Path.p) || (!_v4Path.p->alive(now)) || ((_v4Path.p->address() != _v4ClusterPreferred)&&(path->preferenceRank() >= _v4Path.p->preferenceRank())) ) { + potentialNewPeerPath = &_v4Path; + } + } else if (path->address().ss_family == AF_INET6) { + if ( (!_v6Path.p) || (!_v6Path.p->alive(now)) || ((_v6Path.p->address() != _v6ClusterPreferred)&&(path->preferenceRank() >= _v6Path.p->preferenceRank())) ) { + potentialNewPeerPath = &_v6Path; + } + } + if (potentialNewPeerPath) { + if (verb == Packet::VERB_OK) { + potentialNewPeerPath->lr = now; + potentialNewPeerPath->p = path; #ifdef ZT_ENABLE_CLUSTER - _v6Path.localClusterSuboptimal = isClusterSuboptimalPath; - if (RR->cluster) - RR->cluster->broadcastHavePeer(_id); + potentialNewPeerPath->localClusterSuboptimal = isClusterSuboptimalPath; + if (RR->cluster) + RR->cluster->broadcastHavePeer(_id); #endif - } + } else { + TRACE("got %s via unknown path %s(%s), confirming...",Packet::verbString(verb),_id.address().toString().c_str(),path->address().toString().c_str()); + attemptToContactAt(tPtr,path->localAddress(),path->address(),now,true,path->nextOutgoingCounter()); + path->sent(now); } - } else { - TRACE("got %s via unknown path %s(%s), confirming...",Packet::verbString(verb),_id.address().toString().c_str(),path->address().toString().c_str()); - attemptToContactAt(tPtr,path->localAddress(),path->address(),now,true,path->nextOutgoingCounter()); - path->sent(now); } } } else if (this->trustEstablished(now)) { |