don't add a second instance of a solo node

This commit is contained in:
Stephen Birarda 2013-09-05 17:29:14 -07:00
parent 8c5937dc78
commit 21562abfb1
2 changed files with 62 additions and 54 deletions

View file

@ -167,6 +167,8 @@ int main(int argc, char* const argv[]) {
nodeType,
nodeList->getLastNodeID());
// if addOrUpdateNode returns NULL this was a solo node we already have, don't talk back to it
if (newNode) {
if (newNode->getNodeID() == nodeList->getLastNodeID()) {
nodeList->increaseNodeID();
}
@ -230,6 +232,7 @@ int main(int argc, char* const argv[]) {
broadcastPacket,
(currentBufferPos - startPointer) + numHeaderBytes);
}
}
if (Logstash::shouldSendStats()) {
if (usecTimestampNow() - usecTimestamp(&lastStatSendTime) >= (NODE_COUNT_STAT_INTERVAL_MSECS * 1000)) {

View file

@ -397,6 +397,11 @@ Node* NodeList::addOrUpdateNode(sockaddr* publicSocket, sockaddr* localSocket, c
}
if (node == end()) {
// if we already had this node AND it's a solo type then bust out of here
if (soloNodeOfType(nodeType)) {
return NULL;
}
// we didn't have this node, so add them
Node* newNode = new Node(publicSocket, localSocket, nodeType, nodeId);