mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:47:30 +02:00
fix race for isUpstream and node hole punch
This commit is contained in:
parent
36b4990114
commit
c332244f4f
7 changed files with 16 additions and 18 deletions
|
@ -126,9 +126,8 @@ void AudioMixer::queueReplicatedAudioPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
|
|
||||||
auto replicatedNode = nodeList->addOrUpdateNode(nodeID, NodeType::Agent,
|
auto replicatedNode = nodeList->addOrUpdateNode(nodeID, NodeType::Agent,
|
||||||
message->getSenderSockAddr(), message->getSenderSockAddr(),
|
message->getSenderSockAddr(), message->getSenderSockAddr(),
|
||||||
DEFAULT_AGENT_PERMISSIONS, true);
|
true, true);
|
||||||
replicatedNode->setLastHeardMicrostamp(usecTimestampNow());
|
replicatedNode->setLastHeardMicrostamp(usecTimestampNow());
|
||||||
replicatedNode->setIsUpstream(true);
|
|
||||||
|
|
||||||
// construct a "fake" audio received message from the byte array and packet list information
|
// construct a "fake" audio received message from the byte array and packet list information
|
||||||
auto audioData = message->getMessage().mid(NUM_BYTES_RFC4122_UUID);
|
auto audioData = message->getMessage().mid(NUM_BYTES_RFC4122_UUID);
|
||||||
|
|
|
@ -75,10 +75,9 @@ SharedNodePointer addOrUpdateReplicatedNode(const QUuid& nodeID, const HifiSockA
|
||||||
auto replicatedNode = DependencyManager::get<NodeList>()->addOrUpdateNode(nodeID, NodeType::Agent,
|
auto replicatedNode = DependencyManager::get<NodeList>()->addOrUpdateNode(nodeID, NodeType::Agent,
|
||||||
senderSockAddr,
|
senderSockAddr,
|
||||||
senderSockAddr,
|
senderSockAddr,
|
||||||
DEFAULT_AGENT_PERMISSIONS, true);
|
true, true);
|
||||||
|
|
||||||
replicatedNode->setLastHeardMicrostamp(usecTimestampNow());
|
replicatedNode->setLastHeardMicrostamp(usecTimestampNow());
|
||||||
replicatedNode->setIsUpstream(true);
|
|
||||||
|
|
||||||
return replicatedNode;
|
return replicatedNode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -570,9 +570,8 @@ void LimitedNodeList::handleNodeKill(const SharedNodePointer& node) {
|
||||||
|
|
||||||
SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
||||||
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
||||||
const NodePermissions& permissions,
|
bool isReplicated, bool isUpstream,
|
||||||
bool isReplicated,
|
const QUuid& connectionSecret, const NodePermissions& permissions) {
|
||||||
const QUuid& connectionSecret) {
|
|
||||||
QReadLocker readLocker(&_nodeMutex);
|
QReadLocker readLocker(&_nodeMutex);
|
||||||
NodeHash::const_iterator it = _nodeHash.find(uuid);
|
NodeHash::const_iterator it = _nodeHash.find(uuid);
|
||||||
|
|
||||||
|
@ -584,11 +583,16 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
|
||||||
matchingNode->setPermissions(permissions);
|
matchingNode->setPermissions(permissions);
|
||||||
matchingNode->setConnectionSecret(connectionSecret);
|
matchingNode->setConnectionSecret(connectionSecret);
|
||||||
matchingNode->setIsReplicated(isReplicated);
|
matchingNode->setIsReplicated(isReplicated);
|
||||||
|
matchingNode->setIsUpstream(isUpstream);
|
||||||
|
|
||||||
return matchingNode;
|
return matchingNode;
|
||||||
} else {
|
} else {
|
||||||
// we didn't have this node, so add them
|
// we didn't have this node, so add them
|
||||||
Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket, permissions, isReplicated, connectionSecret);
|
Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket);
|
||||||
|
newNode->setIsReplicated(isReplicated);
|
||||||
|
newNode->setIsUpstream(isUpstream);
|
||||||
|
newNode->setConnectionSecret(connectionSecret);
|
||||||
|
newNode->setPermissions(permissions);
|
||||||
|
|
||||||
// move the newly constructed node to the LNL thread
|
// move the newly constructed node to the LNL thread
|
||||||
newNode->moveToThread(thread());
|
newNode->moveToThread(thread());
|
||||||
|
|
|
@ -145,8 +145,9 @@ public:
|
||||||
|
|
||||||
SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
||||||
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
||||||
const NodePermissions& permissions = DEFAULT_AGENT_PERMISSIONS,
|
bool isReplicated = false, bool isUpstream = false,
|
||||||
bool isReplicated = false, const QUuid& connectionSecret = QUuid());
|
const QUuid& connectionSecret = QUuid(),
|
||||||
|
const NodePermissions& permissions = DEFAULT_AGENT_PERMISSIONS);
|
||||||
|
|
||||||
static bool parseSTUNResponse(udt::BasePacket* packet, QHostAddress& newPublicAddress, uint16_t& newPublicPort);
|
static bool parseSTUNResponse(udt::BasePacket* packet, QHostAddress& newPublicAddress, uint16_t& newPublicPort);
|
||||||
bool hasCompletedInitialSTUN() const { return _hasCompletedInitialSTUN; }
|
bool hasCompletedInitialSTUN() const { return _hasCompletedInitialSTUN; }
|
||||||
|
|
|
@ -73,17 +73,13 @@ NodeType_t NodeType::fromString(QString type) {
|
||||||
|
|
||||||
|
|
||||||
Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket,
|
Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket,
|
||||||
const HifiSockAddr& localSocket, const NodePermissions& permissions, bool isReplicated,
|
const HifiSockAddr& localSocket, QObject* parent) :
|
||||||
const QUuid& connectionSecret, QObject* parent) :
|
|
||||||
NetworkPeer(uuid, publicSocket, localSocket, parent),
|
NetworkPeer(uuid, publicSocket, localSocket, parent),
|
||||||
_type(type),
|
_type(type),
|
||||||
_connectionSecret(connectionSecret),
|
|
||||||
_isReplicated(isReplicated),
|
|
||||||
_pingMs(-1), // "Uninitialized"
|
_pingMs(-1), // "Uninitialized"
|
||||||
_clockSkewUsec(0),
|
_clockSkewUsec(0),
|
||||||
_mutex(),
|
_mutex(),
|
||||||
_clockSkewMovingPercentile(30, 0.8f), // moving 80th percentile of 30 samples
|
_clockSkewMovingPercentile(30, 0.8f) // moving 80th percentile of 30 samples
|
||||||
_permissions(permissions)
|
|
||||||
{
|
{
|
||||||
// Update socket's object name
|
// Update socket's object name
|
||||||
setType(_type);
|
setType(_type);
|
||||||
|
|
|
@ -40,7 +40,6 @@ public:
|
||||||
|
|
||||||
Node(const QUuid& uuid, NodeType_t type,
|
Node(const QUuid& uuid, NodeType_t type,
|
||||||
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
||||||
const NodePermissions& permissions, bool isReplicated, const QUuid& connectionSecret = QUuid(),
|
|
||||||
QObject* parent = nullptr);
|
QObject* parent = nullptr);
|
||||||
|
|
||||||
bool operator==(const Node& otherNode) const { return _uuid == otherNode._uuid; }
|
bool operator==(const Node& otherNode) const { return _uuid == otherNode._uuid; }
|
||||||
|
|
|
@ -667,7 +667,7 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
|
||||||
packetStream >> connectionUUID;
|
packetStream >> connectionUUID;
|
||||||
|
|
||||||
SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket,
|
SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket,
|
||||||
nodeLocalSocket, permissions, isReplicated, connectionUUID);
|
nodeLocalSocket, isReplicated, false, connectionUUID, permissions);
|
||||||
|
|
||||||
// nodes that are downstream of our own type are kept alive when we hear about them from the domain server
|
// 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)) {
|
if (node->getType() == NodeType::downstreamType(_ownerType)) {
|
||||||
|
|
Loading…
Reference in a new issue