mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 02:32:43 +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;
|
||||
}
|
||||
|
||||
assert(_localIDs.size() < std::numeric_limits<LocalIDs::value_type>::max() - 2);
|
||||
|
||||
Node::LocalID newLocalID;
|
||||
do {
|
||||
newLocalID = _currentLocalID;
|
||||
_currentLocalID += _idIncrement;
|
||||
} while (newLocalID == 0 || _localIDToUUID.find(newLocalID) != _localIDToUUID.end());
|
||||
} while (newLocalID == 0 || _localIDs.find(newLocalID) != _localIDs.end());
|
||||
|
||||
_uuidToLocalID.emplace(uuid, newLocalID);
|
||||
_localIDToUUID.emplace(newLocalID, uuid);
|
||||
_localIDs.insert(newLocalID);
|
||||
return newLocalID;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#define hifi_DomainGatekeeper_h
|
||||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
@ -129,9 +130,9 @@ private:
|
|||
size_t operator()(const QUuid& uuid) const { return qHash(uuid); }
|
||||
};
|
||||
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;
|
||||
LocalIDToUUID _localIDToUUID;
|
||||
|
||||
Node::LocalID _currentLocalID;
|
||||
quint16 _idIncrement;
|
||||
|
|
|
@ -2905,7 +2905,7 @@ void DomainServer::updateReplicationNodes(ReplicationServerDirection direction)
|
|||
// manually add the replication node to our node list
|
||||
auto node = nodeList->addOrUpdateNode(QUuid::createUuid(), replicationServer.nodeType,
|
||||
replicationServer.sockAddr, replicationServer.sockAddr,
|
||||
false, direction == Upstream);
|
||||
0, false, direction == Upstream);
|
||||
node->setIsForcedNeverSilent(true);
|
||||
|
||||
qDebug() << "Adding" << (direction == Upstream ? "upstream" : "downstream")
|
||||
|
|
|
@ -695,6 +695,7 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
|
|||
|
||||
auto oldSoloNode = previousSoloIt->second;
|
||||
|
||||
_localIDMap.erase(oldSoloNode->getLocalID());
|
||||
_nodeHash.unsafe_erase(previousSoloIt);
|
||||
handleNodeKill(oldSoloNode);
|
||||
|
||||
|
@ -850,6 +851,9 @@ void LimitedNodeList::removeSilentNodes() {
|
|||
});
|
||||
|
||||
foreach(const SharedNodePointer& killedNode, killedNodes) {
|
||||
_nodeMutex.lockForWrite();
|
||||
_localIDMap.erase(killedNode->getLocalID());
|
||||
_nodeMutex.unlock();
|
||||
handleNodeKill(killedNode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,22 @@
|
|||
class NLPacket : public udt::Packet {
|
||||
Q_OBJECT
|
||||
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 |
|
||||
//
|
||||
|
@ -41,7 +57,7 @@ public:
|
|||
// | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | | |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
||||
// NLPacket Header Format
|
||||
//
|
||||
|
||||
using LocalID = NetworkLocalID;
|
||||
static const int NUM_BYTES_LOCALID = sizeof(LocalID);
|
||||
|
|
Loading…
Reference in a new issue