Showing the changes to assignment-client/src/AssignmentClientMonitor.cpp (1 of 2 files). Show all
Unified · Split
| @@ -87,10 +87,12 @@ void AssignmentClientMonitor::spawnChildClient() { · 86 unmodified lines | ||
| 87 | 87 | assignmentClient->setProcessChannelMode(QProcess::ForwardedChannels); |
| 88 | 88 | |
| 89 | 89 | assignmentClient->start(applicationFilePath(), _childArguments); |
| 90 | + | |
| 90 | 91 | qDebug() << "Spawned a child client with PID" << assignmentClient->pid(); |
| 91 | 92 | } |
| 92 | 93 | |
| 93 | 94 | |
| 95 | + | |
| 94 | 96 | void AssignmentClientMonitor::checkSpares() { |
| 95 | 97 | auto nodeList = DependencyManager::get<NodeList>(); |
| 96 | 98 | QUuid aSpareId = ""; |
| @@ -100,7 +102,6 @@ void AssignmentClientMonitor::checkSpares() { · 3 unmodified lines | ||
| 100 | 102 | |
| 101 | 103 | nodeList->eachNode([&](const SharedNodePointer& node){ |
| 102 | 104 | AssignmentClientChildData *childData = static_cast<AssignmentClientChildData*>(node->getLinkedData()); |
| 103 | − qDebug() << " " << node->getUUID() << childData->getChildType(); | |
| 104 | 105 | if (childData->getChildType() == "none") { |
| 105 | 106 | spareCount ++; |
| 106 | 107 | aSpareId = node->getUUID(); |
| @@ -142,17 +143,20 @@ void AssignmentClientMonitor::readPendingDatagrams() { · 35 unmodified lines | ||
| 142 | 143 | QUuid packetUUID = uuidFromPacketHeader(receivedPacket); |
| 143 | 144 | SharedNodePointer matchingNode = nodeList->sendingNodeForPacket(receivedPacket); |
| 144 | 145 | if (!matchingNode) { |
| 145 | − // XXX only do this if from local machine | |
| 146 | − if (!packetUUID.isNull()) { | |
| 147 | − matchingNode = DependencyManager::get<LimitedNodeList>()->addOrUpdateNode | |
| 148 | − (packetUUID, NodeType::Unassigned, senderSockAddr, senderSockAddr, false); | |
| 149 | − AssignmentClientChildData *childData = new AssignmentClientChildData("unknown"); | |
| 150 | − matchingNode->setLinkedData(childData); | |
| 151 | − } else { | |
| 152 | − // tell unknown assignment-client child to exit. | |
| 153 | − qDebug() << "asking unknown child to exit."; | |
| 154 | − QByteArray diePacket = byteArrayWithPopulatedHeader(PacketTypeStopNode); | |
| 155 | − nodeList->writeUnverifiedDatagram(diePacket, senderSockAddr); | |
| 146 | + // The parent only expects to be talking with prorams running on this same machine. | |
| 147 | + if (senderSockAddr.getAddress() == QHostAddress::LocalHost || | |
| 148 | + senderSockAddr.getAddress() == QHostAddress::LocalHostIPv6) { | |
| 149 | + if (!packetUUID.isNull()) { | |
| 150 | + matchingNode = DependencyManager::get<LimitedNodeList>()->addOrUpdateNode | |
| 151 | + (packetUUID, NodeType::Unassigned, senderSockAddr, senderSockAddr, false); | |
| 152 | + AssignmentClientChildData *childData = new AssignmentClientChildData("unknown"); | |
| 153 | + matchingNode->setLinkedData(childData); | |
| 154 | + } else { | |
| 155 | + // tell unknown assignment-client child to exit. | |
| 156 | + qDebug() << "asking unknown child to exit."; | |
| 157 | + QByteArray diePacket = byteArrayWithPopulatedHeader(PacketTypeStopNode); | |
| 158 | + nodeList->writeUnverifiedDatagram(diePacket, senderSockAddr); | |
| 159 | + } | |
| 156 | 160 | } |
| 157 | 161 | } |
| 158 | 162 | |