mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-28 06:50:00 +00:00
Cluster fix: was accumulating remote endpoints endlessly.
This commit is contained in:
parent
2a3dd53952
commit
964b30902a
@ -143,13 +143,20 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
|
|||||||
return;
|
return;
|
||||||
const uint16_t fromMemberId = dmsg.at<uint16_t>(0);
|
const uint16_t fromMemberId = dmsg.at<uint16_t>(0);
|
||||||
unsigned int ptr = 2;
|
unsigned int ptr = 2;
|
||||||
if (fromMemberId == _id)
|
if (fromMemberId == _id) // sanity check: we don't talk to ourselves
|
||||||
return;
|
return;
|
||||||
const uint16_t toMemberId = dmsg.at<uint16_t>(ptr);
|
const uint16_t toMemberId = dmsg.at<uint16_t>(ptr);
|
||||||
ptr += 2;
|
ptr += 2;
|
||||||
if (toMemberId != _id)
|
if (toMemberId != _id) // sanity check: message not for us?
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
{ // make sure sender is actually considered a member
|
||||||
|
Mutex::Lock _l3(_memberIds_m);
|
||||||
|
if (std::find(_memberIds.begin(),_memberIds.end(),fromMemberId) == _memberIds.end())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
_Member &m = _members[fromMemberId];
|
_Member &m = _members[fromMemberId];
|
||||||
Mutex::Lock mlck(m.lock);
|
Mutex::Lock mlck(m.lock);
|
||||||
|
|
||||||
@ -157,6 +164,8 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
|
|||||||
while (ptr < dmsg.size()) {
|
while (ptr < dmsg.size()) {
|
||||||
const unsigned int mlen = dmsg.at<uint16_t>(ptr); ptr += 2;
|
const unsigned int mlen = dmsg.at<uint16_t>(ptr); ptr += 2;
|
||||||
const unsigned int nextPtr = ptr + mlen;
|
const unsigned int nextPtr = ptr + mlen;
|
||||||
|
if (nextPtr > dmsg.size())
|
||||||
|
break;
|
||||||
|
|
||||||
int mtype = -1;
|
int mtype = -1;
|
||||||
try {
|
try {
|
||||||
@ -176,6 +185,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
|
|||||||
std::string addrs;
|
std::string addrs;
|
||||||
#endif
|
#endif
|
||||||
unsigned int physicalAddressCount = dmsg[ptr++];
|
unsigned int physicalAddressCount = dmsg[ptr++];
|
||||||
|
m.zeroTierPhysicalEndpoints.clear();
|
||||||
for(unsigned int i=0;i<physicalAddressCount;++i) {
|
for(unsigned int i=0;i<physicalAddressCount;++i) {
|
||||||
m.zeroTierPhysicalEndpoints.push_back(InetAddress());
|
m.zeroTierPhysicalEndpoints.push_back(InetAddress());
|
||||||
ptr += m.zeroTierPhysicalEndpoints.back().deserialize(dmsg,ptr);
|
ptr += m.zeroTierPhysicalEndpoints.back().deserialize(dmsg,ptr);
|
||||||
@ -192,7 +202,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
|
|||||||
}
|
}
|
||||||
m.lastReceivedAliveAnnouncement = RR->node->now();
|
m.lastReceivedAliveAnnouncement = RR->node->now();
|
||||||
#ifdef ZT_TRACE
|
#ifdef ZT_TRACE
|
||||||
TRACE("[%u] I'm alive! send me peers at %s",(unsigned int)fromMemberId,addrs.c_str());
|
TRACE("[%u] I'm alive! peers may be redirected to: %s",(unsigned int)fromMemberId,addrs.c_str());
|
||||||
#endif
|
#endif
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -350,6 +360,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
|
|||||||
TRACE("invalid message (outer loop), discarding");
|
TRACE("invalid message (outer loop), discarding");
|
||||||
// drop invalids
|
// drop invalids
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Cluster::sendViaCluster(const Address &fromPeerAddress,const Address &toPeerAddress,const void *data,unsigned int len)
|
bool Cluster::sendViaCluster(const Address &fromPeerAddress,const Address &toPeerAddress,const void *data,unsigned int len)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user