diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-11-08 11:06:14 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-11-08 11:06:14 -0800 |
commit | 4166d8ca35ded34180d60b56105a853dd6b02ff4 (patch) | |
tree | 3464cfb6e36f67ec5a8fe6f59eae8cbc40759c40 /node | |
parent | 53e7e950f187008939dd5021f9d5f635f995f022 (diff) | |
download | infinitytier-4166d8ca35ded34180d60b56105a853dd6b02ff4.tar.gz infinitytier-4166d8ca35ded34180d60b56105a853dd6b02ff4.zip |
Fix a deadlock and some more work on RethinkDB (for central) integration.
Diffstat (limited to 'node')
-rw-r--r-- | node/Peer.cpp | 59 |
1 files changed, 8 insertions, 51 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp index a3682a97..2d562f12 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -78,54 +78,6 @@ void Peer::received( { const int64_t now = RR->node->now(); -/* -#ifdef ZT_ENABLE_CLUSTER - bool isClusterSuboptimalPath = false; - if ((RR->cluster)&&(hops == 0)) { - // Note: findBetterEndpoint() is first since we still want to check - // for a better endpoint even if we don't actually send a redirect. - InetAddress redirectTo; - if ( (verb != Packet::VERB_OK) && (verb != Packet::VERB_ERROR) && (verb != Packet::VERB_RENDEZVOUS) && (verb != Packet::VERB_PUSH_DIRECT_PATHS) && (RR->cluster->findBetterEndpoint(redirectTo,_id.address(),path->address(),false)) ) { - if (_vProto >= 5) { - // For newer peers we can send a more idiomatic verb: PUSH_DIRECT_PATHS. - Packet outp(_id.address(),RR->identity.address(),Packet::VERB_PUSH_DIRECT_PATHS); - outp.append((uint16_t)1); // count == 1 - outp.append((uint8_t)ZT_PUSH_DIRECT_PATHS_FLAG_CLUSTER_REDIRECT); // flags: cluster redirect - outp.append((uint16_t)0); // no extensions - if (redirectTo.ss_family == AF_INET) { - outp.append((uint8_t)4); - outp.append((uint8_t)6); - outp.append(redirectTo.rawIpData(),4); - } else { - outp.append((uint8_t)6); - outp.append((uint8_t)18); - outp.append(redirectTo.rawIpData(),16); - } - outp.append((uint16_t)redirectTo.port()); - outp.armor(_key,true,path->nextOutgoingCounter()); - path->send(RR,tPtr,outp.data(),outp.size(),now); - } else { - // For older peers we use RENDEZVOUS to coax them into contacting us elsewhere. - Packet outp(_id.address(),RR->identity.address(),Packet::VERB_RENDEZVOUS); - outp.append((uint8_t)0); // no flags - RR->identity.address().appendTo(outp); - outp.append((uint16_t)redirectTo.port()); - if (redirectTo.ss_family == AF_INET) { - outp.append((uint8_t)4); - outp.append(redirectTo.rawIpData(),4); - } else { - outp.append((uint8_t)16); - outp.append(redirectTo.rawIpData(),16); - } - outp.armor(_key,true,path->nextOutgoingCounter()); - path->send(RR,tPtr,outp.data(),outp.size(),now); - } - isClusterSuboptimalPath = true; - } - } -#endif -*/ - _lastReceive = now; switch (verb) { case Packet::VERB_FRAME: @@ -163,6 +115,7 @@ void Peer::received( } } + bool attemptToContact = false; if ((!havePath)&&(RR->node->shouldUsePathForZeroTierTraffic(tPtr,_id.address(),path->localSocket(),path->address()))) { Mutex::Lock _l(_paths_m); @@ -201,13 +154,17 @@ void Peer::received( _paths[replacePath].p = path; _paths[replacePath].priority = 1; } else { - attemptToContactAt(tPtr,path->localSocket(),path->address(),now,true,path->nextOutgoingCounter()); - path->sent(now); - RR->t->peerConfirmingUnknownPath(tPtr,networkId,*this,path,packetId,verb); + attemptToContact = true; } } } } + + if (attemptToContact) { + attemptToContactAt(tPtr,path->localSocket(),path->address(),now,true,path->nextOutgoingCounter()); + path->sent(now); + RR->t->peerConfirmingUnknownPath(tPtr,networkId,*this,path,packetId,verb); + } } // If we have a trust relationship periodically push a message enumerating |