summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-27 16:52:44 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-27 16:52:44 -0700
commit4221552c0b3283d106a7c3a44959a02fefd31af6 (patch)
tree920f7ed496ce89f9d8f278985cbede83682ec7c2 /node
parentcc1b275ad97bf186f21b487aa57d7893bee3c956 (diff)
downloadinfinitytier-4221552c0b3283d106a7c3a44959a02fefd31af6.tar.gz
infinitytier-4221552c0b3283d106a7c3a44959a02fefd31af6.zip
Use getPeerNoCache() in Cluster to avoid keeping all peers cached everywhere.
Diffstat (limited to 'node')
-rw-r--r--node/Cluster.cpp5
-rw-r--r--node/Topology.hpp17
2 files changed, 20 insertions, 2 deletions
diff --git a/node/Cluster.cpp b/node/Cluster.cpp
index 0797d83d..0535f9ee 100644
--- a/node/Cluster.cpp
+++ b/node/Cluster.cpp
@@ -210,6 +210,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
} break;
case STATE_MESSAGE_HAVE_PEER: {
+ const uint64_t now = RR->node->now();
Identity id;
InetAddress physicalAddress;
ptr += id.deserialize(dmsg,ptr);
@@ -217,7 +218,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
if (id) {
// Forget any paths that we have to this peer at its address
if (physicalAddress) {
- SharedPtr<Peer> myPeerRecord(RR->topology->getPeer(id.address()));
+ SharedPtr<Peer> myPeerRecord(RR->topology->getPeerNoCache(id.address(),now));
if (myPeerRecord)
myPeerRecord->removePathByAddress(physicalAddress);
}
@@ -229,7 +230,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
{
Mutex::Lock _l2(_peerAffinities_m);
_PA &pa = _peerAffinities[id.address()];
- pa.ts = RR->node->now();
+ pa.ts = now;
pa.mid = fromMemberId;
}
TRACE("[%u] has %s @ %s",(unsigned int)fromMemberId,id.address().toString().c_str(),physicalAddress.toString().c_str());
diff --git a/node/Topology.hpp b/node/Topology.hpp
index ee9827b9..16836e07 100644
--- a/node/Topology.hpp
+++ b/node/Topology.hpp
@@ -79,6 +79,23 @@ public:
SharedPtr<Peer> getPeer(const Address &zta);
/**
+ * Get a peer only if it is presently in memory (no disk cache)
+ *
+ * @param zta ZeroTier address
+ * @param now Current time
+ */
+ inline SharedPtr<Peer> getPeerNoCache(const Address &zta,const uint64_t now)
+ {
+ Mutex::Lock _l(_lock);
+ const SharedPtr<Peer> *ap = _peers.get(zta);
+ if (ap) {
+ (*ap)->use(now);
+ return *ap;
+ }
+ return SharedPtr<Peer>();
+ }
+
+ /**
* Get the identity of a peer
*
* @param zta ZeroTier address of peer