mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-29 09:30:23 +02:00
Merge pull request #8279 from birarda/master
fix crash with multiple solo nodes in closeCurrentPacket
This commit is contained in:
commit
0632f6df2d
2 changed files with 30 additions and 3 deletions
|
@ -34,7 +34,7 @@
|
||||||
#include "NetworkLogging.h"
|
#include "NetworkLogging.h"
|
||||||
#include "udt/Packet.h"
|
#include "udt/Packet.h"
|
||||||
|
|
||||||
const char SOLO_NODE_TYPES[2] = {
|
const std::set<NodeType_t> SOLO_NODE_TYPES = {
|
||||||
NodeType::AvatarMixer,
|
NodeType::AvatarMixer,
|
||||||
NodeType::AudioMixer
|
NodeType::AudioMixer
|
||||||
};
|
};
|
||||||
|
@ -551,7 +551,33 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
|
||||||
|
|
||||||
SharedNodePointer newNodePointer(newNode, &QObject::deleteLater);
|
SharedNodePointer newNodePointer(newNode, &QObject::deleteLater);
|
||||||
|
|
||||||
|
// if this is a solo node type, we assume that the DS has replaced its assignment and we should kill the previous node
|
||||||
|
if (SOLO_NODE_TYPES.count(newNode->getType())) {
|
||||||
|
// while we still have the read lock, see if there is a previous solo node we'll need to remove
|
||||||
|
auto previousSoloIt = std::find_if(_nodeHash.cbegin(), _nodeHash.cend(), [newNode](const UUIDNodePair& nodePair){
|
||||||
|
return nodePair.second->getType() == newNode->getType();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (previousSoloIt != _nodeHash.cend()) {
|
||||||
|
// we have a previous solo node, switch to a write lock so we can remove it
|
||||||
|
readLocker.unlock();
|
||||||
|
|
||||||
|
QWriteLocker writeLocker(&_nodeMutex);
|
||||||
|
|
||||||
|
auto oldSoloNode = previousSoloIt->second;
|
||||||
|
|
||||||
|
_nodeHash.unsafe_erase(previousSoloIt);
|
||||||
|
handleNodeKill(oldSoloNode);
|
||||||
|
|
||||||
|
// convert the current lock back to a read lock for insertion of new node
|
||||||
|
writeLocker.unlock();
|
||||||
|
readLocker.relock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert the new node and release our read lock
|
||||||
_nodeHash.insert(UUIDNodePair(newNode->getUUID(), newNodePointer));
|
_nodeHash.insert(UUIDNodePair(newNode->getUUID(), newNodePointer));
|
||||||
|
readLocker.unlock();
|
||||||
|
|
||||||
qCDebug(networking) << "Added" << *newNode;
|
qCDebug(networking) << "Added" << *newNode;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -46,7 +47,7 @@
|
||||||
|
|
||||||
const quint64 NODE_SILENCE_THRESHOLD_MSECS = 5 * 1000;
|
const quint64 NODE_SILENCE_THRESHOLD_MSECS = 5 * 1000;
|
||||||
|
|
||||||
extern const char SOLO_NODE_TYPES[2];
|
extern const std::set<NodeType_t> SOLO_NODE_TYPES;
|
||||||
|
|
||||||
const char DEFAULT_ASSIGNMENT_SERVER_HOSTNAME[] = "localhost";
|
const char DEFAULT_ASSIGNMENT_SERVER_HOSTNAME[] = "localhost";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue