mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Handle all case of nodes being deleted from nodelist
Delete erased nodes from local ID mapping, as this uses SharedPointer. Don't keep the mapping from local IDs to UUIDs in GateKeeper as it isn't used.
This commit is contained in:
parent
f823f63211
commit
b409e04734
5 changed files with 29 additions and 6 deletions
|
@ -1033,13 +1033,15 @@ Node::LocalID DomainGatekeeper::findOrCreateLocalID(const QUuid& uuid) {
|
||||||
return existingLocalIDIt->second;
|
return existingLocalIDIt->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(_localIDs.size() < std::numeric_limits<LocalIDs::value_type>::max() - 2);
|
||||||
|
|
||||||
Node::LocalID newLocalID;
|
Node::LocalID newLocalID;
|
||||||
do {
|
do {
|
||||||
newLocalID = _currentLocalID;
|
newLocalID = _currentLocalID;
|
||||||
_currentLocalID += _idIncrement;
|
_currentLocalID += _idIncrement;
|
||||||
} while (newLocalID == 0 || _localIDToUUID.find(newLocalID) != _localIDToUUID.end());
|
} while (newLocalID == 0 || _localIDs.find(newLocalID) != _localIDs.end());
|
||||||
|
|
||||||
_uuidToLocalID.emplace(uuid, newLocalID);
|
_uuidToLocalID.emplace(uuid, newLocalID);
|
||||||
_localIDToUUID.emplace(newLocalID, uuid);
|
_localIDs.insert(newLocalID);
|
||||||
return newLocalID;
|
return newLocalID;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#define hifi_DomainGatekeeper_h
|
#define hifi_DomainGatekeeper_h
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtNetwork/QNetworkReply>
|
#include <QtNetwork/QNetworkReply>
|
||||||
|
@ -129,9 +130,9 @@ private:
|
||||||
size_t operator()(const QUuid& uuid) const { return qHash(uuid); }
|
size_t operator()(const QUuid& uuid) const { return qHash(uuid); }
|
||||||
};
|
};
|
||||||
using UUIDToLocalID = std::unordered_map<QUuid, Node::LocalID, UuidHash> ;
|
using UUIDToLocalID = std::unordered_map<QUuid, Node::LocalID, UuidHash> ;
|
||||||
using LocalIDToUUID = std::unordered_map<Node::LocalID, QUuid>;
|
using LocalIDs = std::unordered_set<Node::LocalID>;
|
||||||
|
LocalIDs _localIDs;
|
||||||
UUIDToLocalID _uuidToLocalID;
|
UUIDToLocalID _uuidToLocalID;
|
||||||
LocalIDToUUID _localIDToUUID;
|
|
||||||
|
|
||||||
Node::LocalID _currentLocalID;
|
Node::LocalID _currentLocalID;
|
||||||
quint16 _idIncrement;
|
quint16 _idIncrement;
|
||||||
|
|
|
@ -2905,7 +2905,7 @@ void DomainServer::updateReplicationNodes(ReplicationServerDirection direction)
|
||||||
// manually add the replication node to our node list
|
// manually add the replication node to our node list
|
||||||
auto node = nodeList->addOrUpdateNode(QUuid::createUuid(), replicationServer.nodeType,
|
auto node = nodeList->addOrUpdateNode(QUuid::createUuid(), replicationServer.nodeType,
|
||||||
replicationServer.sockAddr, replicationServer.sockAddr,
|
replicationServer.sockAddr, replicationServer.sockAddr,
|
||||||
false, direction == Upstream);
|
0, false, direction == Upstream);
|
||||||
node->setIsForcedNeverSilent(true);
|
node->setIsForcedNeverSilent(true);
|
||||||
|
|
||||||
qDebug() << "Adding" << (direction == Upstream ? "upstream" : "downstream")
|
qDebug() << "Adding" << (direction == Upstream ? "upstream" : "downstream")
|
||||||
|
|
|
@ -695,6 +695,7 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
|
||||||
|
|
||||||
auto oldSoloNode = previousSoloIt->second;
|
auto oldSoloNode = previousSoloIt->second;
|
||||||
|
|
||||||
|
_localIDMap.erase(oldSoloNode->getLocalID());
|
||||||
_nodeHash.unsafe_erase(previousSoloIt);
|
_nodeHash.unsafe_erase(previousSoloIt);
|
||||||
handleNodeKill(oldSoloNode);
|
handleNodeKill(oldSoloNode);
|
||||||
|
|
||||||
|
@ -850,6 +851,9 @@ void LimitedNodeList::removeSilentNodes() {
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach(const SharedNodePointer& killedNode, killedNodes) {
|
foreach(const SharedNodePointer& killedNode, killedNodes) {
|
||||||
|
_nodeMutex.lockForWrite();
|
||||||
|
_localIDMap.erase(killedNode->getLocalID());
|
||||||
|
_nodeMutex.unlock();
|
||||||
handleNodeKill(killedNode);
|
handleNodeKill(killedNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,22 @@
|
||||||
class NLPacket : public udt::Packet {
|
class NLPacket : public udt::Packet {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
//
|
||||||
|
// Current NLPacket format:
|
||||||
|
//
|
||||||
|
// | BYTE | BYTE | BYTE | BYTE |
|
||||||
|
// 0 1 2 3
|
||||||
|
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | Packet Type | Version | Local Node ID - sourced only |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// | |
|
||||||
|
// | MD5 Verification - 16 bytes |
|
||||||
|
// | (ONLY FOR VERIFIED PACKETS) |
|
||||||
|
// | |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
|
// Old NLPacket format:
|
||||||
//
|
//
|
||||||
// | BYTE | BYTE | BYTE | BYTE |
|
// | BYTE | BYTE | BYTE | BYTE |
|
||||||
//
|
//
|
||||||
|
@ -41,7 +57,7 @@ public:
|
||||||
// | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
// | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
// | | |
|
// | | |
|
||||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
||||||
// NLPacket Header Format
|
//
|
||||||
|
|
||||||
using LocalID = NetworkLocalID;
|
using LocalID = NetworkLocalID;
|
||||||
static const int NUM_BYTES_LOCALID = sizeof(LocalID);
|
static const int NUM_BYTES_LOCALID = sizeof(LocalID);
|
||||||
|
|
Loading…
Reference in a new issue