From f4cf1c0291b1f3b202570c0fd67c694e131b2036 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 18 Nov 2015 17:33:22 -0800 Subject: [PATCH 1/2] only broadcast removed node messages to interested nodes --- domain-server/src/DomainServer.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index d7bcec2431..653f0e84cd 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -1835,14 +1835,25 @@ void DomainServer::processNodeDisconnectRequestPacket(QSharedPointer p qDebug() << "Received a disconnect request from node with UUID" << nodeUUID; - if (limitedNodeList->killNodeWithUUID(nodeUUID)) { + // we want to check what type this node was before going to kill it so that we can avoid sending the RemovedNode + // packet to nodes that don't care about this type + auto node = limitedNodeList->nodeWithUUID(nodeUUID); + + if (node) { + auto nodeType = node->getType(); + limitedNodeList->killNodeWithUUID(nodeUUID); + static auto removedNodePacket = NLPacket::create(PacketType::DomainServerRemovedNode, NUM_BYTES_RFC4122_UUID); removedNodePacket->reset(); removedNodePacket->write(nodeUUID.toRfc4122()); // broadcast out the DomainServerRemovedNode message - limitedNodeList->eachNode([&limitedNodeList](const SharedNodePointer& otherNode){ + limitedNodeList->eachMatchingNode([&nodeType](const SharedNodePointer& otherNode) -> bool { + // only send the removed node packet to nodes that care about the type of node this was + auto nodeLinkedData = dynamic_cast(otherNode->getLinkedData()); + return (nodeLinkedData != nullptr) && nodeLinkedData->getNodeInterestSet().contains(nodeType); + }, [&limitedNodeList](const SharedNodePointer& otherNode){ limitedNodeList->sendUnreliablePacket(*removedNodePacket, *otherNode); }); } From 3fba1f8445422e3a639dc4a93c7c0fb776ffd8fd Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 18 Nov 2015 17:46:32 -0800 Subject: [PATCH 2/2] better variable naming for nodeToKill --- domain-server/src/DomainServer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 653f0e84cd..b4243ef8a0 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -1837,10 +1837,10 @@ void DomainServer::processNodeDisconnectRequestPacket(QSharedPointer p // we want to check what type this node was before going to kill it so that we can avoid sending the RemovedNode // packet to nodes that don't care about this type - auto node = limitedNodeList->nodeWithUUID(nodeUUID); + auto nodeToKill = limitedNodeList->nodeWithUUID(nodeUUID); - if (node) { - auto nodeType = node->getType(); + if (nodeToKill) { + auto nodeType = nodeToKill->getType(); limitedNodeList->killNodeWithUUID(nodeUUID); static auto removedNodePacket = NLPacket::create(PacketType::DomainServerRemovedNode, NUM_BYTES_RFC4122_UUID);