diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 58100a6336..25f28fda32 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -703,8 +703,11 @@ void AvatarMixer::handleRadiusIgnoreRequestPacket(QSharedPointer(); const QUuid& connectionToken = _domainHandler.getConnectionToken(); - bool requiresUsernameSignature = !_domainHandler.isConnected() && !connectionToken.isNull(); + bool requiresUsernameSignature = !domainIsConnected && !connectionToken.isNull(); if (requiresUsernameSignature && !accountManager->getAccountInfo().hasPrivateKey()) { qWarning() << "A keypair is required to present a username signature to the domain-server" @@ -352,6 +358,7 @@ void NodeList::sendDomainServerCheckIn() { QDataStream packetStream(domainPacket.get()); + HifiSockAddr localSockAddr = _localSockAddr; if (domainPacketType == PacketType::DomainConnectRequest) { #if (PR_BUILD || DEV_BUILD) @@ -360,13 +367,9 @@ void NodeList::sendDomainServerCheckIn() { } #endif - QUuid connectUUID; + QUuid connectUUID = _domainHandler.getAssignmentUUID(); - if (!_domainHandler.getAssignmentUUID().isNull()) { - // this is a connect request and we're an assigned node - // so set our packetUUID as the assignment UUID - connectUUID = _domainHandler.getAssignmentUUID(); - } else if (_domainHandler.requiresICE()) { + if (connectUUID.isNull() && _domainHandler.requiresICE()) { // this is a connect request and we're an interface client // that used ice to discover the DS // so send our ICE client UUID with the connect request @@ -382,10 +385,9 @@ void NodeList::sendDomainServerCheckIn() { // if possible, include the MAC address for the current interface in our connect request QString hardwareAddress; - for (auto networkInterface : QNetworkInterface::allInterfaces()) { for (auto interfaceAddress : networkInterface.addressEntries()) { - if (interfaceAddress.ip() == _localSockAddr.getAddress()) { + if (interfaceAddress.ip() == localSockAddr.getAddress()) { // this is the interface whose local IP matches what we've detected the current IP to be hardwareAddress = networkInterface.hardwareAddress(); @@ -409,10 +411,10 @@ void NodeList::sendDomainServerCheckIn() { // pack our data to send to the domain-server including // the hostname information (so the domain-server can see which place name we came in on) - packetStream << _ownerType.load() << _publicSockAddr << _localSockAddr << _nodeTypesOfInterest.toList(); + packetStream << _ownerType.load() << publicSockAddr << localSockAddr << _nodeTypesOfInterest.toList(); packetStream << DependencyManager::get()->getPlaceName(); - if (!_domainHandler.isConnected()) { + if (!domainIsConnected) { DataServerAccountInfo& accountInfo = accountManager->getAccountInfo(); packetStream << accountInfo.getUsername(); @@ -432,9 +434,9 @@ void NodeList::sendDomainServerCheckIn() { checkinCount = std::min(checkinCount, MAX_CHECKINS_TOGETHER); for (int i = 1; i < checkinCount; ++i) { auto packetCopy = domainPacket->createCopy(*domainPacket); - sendPacket(std::move(packetCopy), _domainHandler.getSockAddr()); + sendPacket(std::move(packetCopy), domainSockAddr); } - sendPacket(std::move(domainPacket), _domainHandler.getSockAddr()); + sendPacket(std::move(domainPacket), domainSockAddr); } } diff --git a/libraries/networking/src/ThreadedAssignment.cpp b/libraries/networking/src/ThreadedAssignment.cpp index 012ac242ab..9b9a53b469 100644 --- a/libraries/networking/src/ThreadedAssignment.cpp +++ b/libraries/networking/src/ThreadedAssignment.cpp @@ -102,6 +102,11 @@ void ThreadedAssignment::addPacketStatsAndSendStatsPacket(QJsonObject statsObjec statsObject["io_stats"] = ioStats; + QJsonObject assignmentStats; + assignmentStats["numQueuedCheckIns"] = _numQueuedCheckIns; + + statsObject["assignmentStats"] = assignmentStats; + nodeList->sendStatsToDomainServer(statsObject); } @@ -119,7 +124,10 @@ void ThreadedAssignment::checkInWithDomainServerOrExit() { stop(); } else { auto nodeList = DependencyManager::get(); - QMetaObject::invokeMethod(nodeList.data(), "sendDomainServerCheckIn"); + // Call sendDomainServerCheckIn directly instead of putting it on + // the event queue. Under high load, the event queue can back up + // longer than the total timeout period and cause a restart + nodeList->sendDomainServerCheckIn(); // increase the number of queued check ins _numQueuedCheckIns++;