summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-09 18:01:23 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-09 18:01:23 -0800
commit32ec378e3b5e9c584d45c7316142c73c362dd032 (patch)
treee1986cf92feb930753290e1970444beb33459626 /node
parent2cc50bdb10c0a7849763ae1dfa37ca7707299a16 (diff)
downloadinfinitytier-32ec378e3b5e9c584d45c7316142c73c362dd032.tar.gz
infinitytier-32ec378e3b5e9c584d45c7316142c73c362dd032.zip
Announce that we have peers on the cluster when we first see them to improve startup times, and add a result crunching script to tests/http.
Diffstat (limited to 'node')
-rw-r--r--node/Cluster.cpp11
-rw-r--r--node/Cluster.hpp9
-rw-r--r--node/Peer.cpp5
3 files changed, 25 insertions, 0 deletions
diff --git a/node/Cluster.cpp b/node/Cluster.cpp
index a819372e..ab074b6d 100644
--- a/node/Cluster.cpp
+++ b/node/Cluster.cpp
@@ -363,6 +363,17 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
}
}
+void Cluster::broadcastHavePeer(const Identity &id)
+{
+ Buffer<1024> buf;
+ id.serialize(buf);
+ Mutex::Lock _l(_memberIds_m);
+ for(std::vector<uint16_t>::const_iterator mid(_memberIds.begin());mid!=_memberIds.end();++mid) {
+ Mutex::Lock _l2(_members[*mid].lock);
+ _send(*mid,CLUSTER_MESSAGE_HAVE_PEER,buf.data(),buf.size());
+ }
+}
+
void Cluster::sendViaCluster(const Address &fromPeerAddress,const Address &toPeerAddress,const void *data,unsigned int len,bool unite)
{
if (len > ZT_PROTO_MAX_PACKET_LENGTH) // sanity check
diff --git a/node/Cluster.hpp b/node/Cluster.hpp
index 1c4331b4..6a7cf7ad 100644
--- a/node/Cluster.hpp
+++ b/node/Cluster.hpp
@@ -245,6 +245,15 @@ public:
void handleIncomingStateMessage(const void *msg,unsigned int len);
/**
+ * Broadcast that we have a given peer
+ *
+ * This should be done when new peers are first contacted.
+ *
+ * @param id Identity of peer
+ */
+ void broadcastHavePeer(const Identity &id);
+
+ /**
* Send this packet via another node in this cluster if another node has this peer
*
* This is used in the outgoing packet and relaying logic in Switch to
diff --git a/node/Peer.cpp b/node/Peer.cpp
index de6f00c2..d728cf4c 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -187,6 +187,11 @@ void Peer::received(
_sortPaths(now);
}
+#ifdef ZT_ENABLE_CLUSTER
+ if ((RR->cluster)&&(!suboptimalPath))
+ RR->cluster->broadcastHavePeer(_id);
+#endif
+
} else {
/* If this path is not known, send a HELLO. We don't learn