keep downstream nodes around in domain, alive in upstream

This commit is contained in:
Stephen Birarda 2017-06-14 17:17:14 -07:00
parent 1ed0b693da
commit 224a559602
4 changed files with 12 additions and 1 deletions

View file

@ -2267,6 +2267,7 @@ void DomainServer::updateDownstreamNodes() {
// manually add the downstream node to our node list
auto node = nodeList->addOrUpdateNode(QUuid::createUuid(), downstreamNodeType,
downstreamServerAddr, downstreamServerAddr);
node->setIsForcedAlive(true);
qDebug() << "Adding downstream node:" << node->getUUID() << downstreamServerAddr;

View file

@ -749,7 +749,7 @@ void LimitedNodeList::removeSilentNodes() {
SharedNodePointer node = it->second;
node->getMutex().lock();
if (!NodeType::isDownstream(node->getType())
if (!node->isForcedAlive()
&& (usecTimestampNow() - node->getLastHeardMicrostamp()) > (NODE_SILENCE_THRESHOLD_MSECS * USECS_PER_MSEC)) {
// call the NodeHash erase to get rid of this node
it = _nodeHash.unsafe_erase(it);

View file

@ -76,6 +76,9 @@ public:
float getOutboundBandwidth() const; // in kbps
float getInboundBandwidth() const; // in kbps
bool isForcedAlive() const { return _isForcedAlive; }
void setIsForcedAlive(bool isForcedAlive) { _isForcedAlive = isForcedAlive; }
friend QDataStream& operator<<(QDataStream& out, const NetworkPeer& peer);
friend QDataStream& operator>>(QDataStream& in, NetworkPeer& peer);
public slots:
@ -103,6 +106,8 @@ protected:
QTimer* _pingTimer = NULL;
int _connectionAttempts;
bool _isForcedAlive { false };
};
QDebug operator<<(QDebug debug, const NetworkPeer &peer);

View file

@ -668,6 +668,11 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket,
nodeLocalSocket, permissions, isReplicated, connectionUUID);
// nodes that are downstream of our own type are kept alive when we hear about them from the domain server
if (node->getType() == NodeType::downstreamType(_ownerType)) {
node->setLastHeardMicrostamp(usecTimestampNow());
}
}
void NodeList::sendAssignment(Assignment& assignment) {