mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-14 02:27:38 -07:00
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.
This commit is contained in:
parent
2cc50bdb10
commit
32ec378e3b
5 changed files with 84 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -244,6 +244,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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue