From 80dd0c33568c4977ff2ab805a2d74e7e2ea9afb9 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sun, 20 Apr 2014 20:18:56 -0700 Subject: [PATCH 1/7] fix switching audio device bug --- interface/src/Audio.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 830e2fe69b..698a8db725 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -1068,7 +1068,6 @@ bool Audio::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo) delete _audioOutput; _audioOutput = NULL; - _numInputCallbackBytes = 0; _loopbackOutputDevice = NULL; delete _loopbackAudioOutput; From 36b58b178c33abc9633c9ad5c066f7e044787099 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 01:00:56 -0700 Subject: [PATCH 2/7] have scripted assignments added via config be static --- domain-server/src/DomainServer.cpp | 48 +++++++++++++++++++----------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index f32eb99733..da51009e6a 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -278,7 +278,8 @@ void DomainServer::createScriptedAssignmentsFromArray(const QJsonArray &configAr qDebug() << "Adding scripted assignment to queue -" << *scriptAssignment; qDebug() << "URL for script is" << assignmentURL; - _assignmentQueue.enqueue(SharedAssignmentPointer(scriptAssignment)); + // scripts passed on CL or via JSON are static - so they are added back to the queue if the node dies + addStaticAssignmentToAssignmentHash(scriptAssignment); } } } @@ -740,6 +741,16 @@ QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) { return nodeJson; } +const char ASSIGNMENT_SCRIPT_HOST_LOCATION[] = "resources/web/assignment"; + +QString pathForAssignmentScript(const QUuid& assignmentUUID) { + QString newPath(ASSIGNMENT_SCRIPT_HOST_LOCATION); + newPath += "/"; + // append the UUID for this script as the new filename, remove the curly braces + newPath += uuidStringWithoutCurlyBraces(assignmentUUID); + return newPath; +} + bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url) { const QString JSON_MIME_TYPE = "application/json"; @@ -870,17 +881,13 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url assignmentPool = QString(assignmentPoolValue); } - const char ASSIGNMENT_SCRIPT_HOST_LOCATION[] = "resources/web/assignment"; for (int i = 0; i < numInstances; i++) { // create an assignment for this saved script Assignment* scriptAssignment = new Assignment(Assignment::CreateCommand, Assignment::AgentType, assignmentPool); - QString newPath(ASSIGNMENT_SCRIPT_HOST_LOCATION); - newPath += "/"; - // append the UUID for this script as the new filename, remove the curly braces - newPath += uuidStringWithoutCurlyBraces(scriptAssignment->getUUID()); + QString newPath = pathForAssignmentScript(scriptAssignment->getUUID()); // create a file with the GUID of the assignment in the script host location QFile scriptFile(newPath); @@ -945,6 +952,12 @@ void DomainServer::refreshStaticAssignmentAndAddToQueue(SharedAssignmentPointer& qDebug() << "Reset UUID for assignment -" << *assignment.data() << "- and added to queue. Old UUID was" << uuidStringWithoutCurlyBraces(oldUUID); + if (assignment->getType() == Assignment::AgentType && assignment->getPayload().isEmpty()) { +\ + // if this was an Agent without a script URL, we need to rename the old file so it can be retrieved at the new UUID + QFile::rename(pathForAssignmentScript(oldUUID), pathForAssignmentScript(assignment->getUUID())); + } + // add the static assignment back under the right UUID, and to the queue _staticAssignmentHash.insert(assignment->getUUID(), assignment); @@ -1019,22 +1032,21 @@ SharedAssignmentPointer DomainServer::deployableAssignmentForRequest(const Assig bool assignmentPoolsMatch = assignment->getPool() == requestAssignment.getPool(); if ((requestIsAllTypes || assignmentTypesMatch) && (nietherHasPool || assignmentPoolsMatch)) { - - if (assignment->getType() == Assignment::AgentType) { - // if there is more than one instance to send out, simply decrease the number of instances - return _assignmentQueue.takeAt(sharedAssignment - _assignmentQueue.begin()); - } else { - // remove the assignment from the queue - SharedAssignmentPointer deployableAssignment = _assignmentQueue.takeAt(sharedAssignment - - _assignmentQueue.begin()); - + + // remove the assignment from the queue + SharedAssignmentPointer deployableAssignment = _assignmentQueue.takeAt(sharedAssignment + - _assignmentQueue.begin()); + + if (deployableAssignment->getType() != Assignment::AgentType + || _staticAssignmentHash.contains(deployableAssignment->getUUID())) { + // this is a static assignment // until we get a check-in from that GUID // put assignment back in queue but stick it at the back so the others have a chance to go out _assignmentQueue.enqueue(deployableAssignment); - - // stop looping, we've handed out an assignment - return deployableAssignment; } + + // stop looping, we've handed out an assignment + return deployableAssignment; } else { // push forward the iterator to check the next assignment ++sharedAssignment; From c64ae353746a1a5a25e575b534632a9a5dd2f25a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 01:01:38 -0700 Subject: [PATCH 3/7] remove an extra bracket --- domain-server/src/DomainServer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index da51009e6a..d882bea1c8 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -953,7 +953,6 @@ void DomainServer::refreshStaticAssignmentAndAddToQueue(SharedAssignmentPointer& << uuidStringWithoutCurlyBraces(oldUUID); if (assignment->getType() == Assignment::AgentType && assignment->getPayload().isEmpty()) { -\ // if this was an Agent without a script URL, we need to rename the old file so it can be retrieved at the new UUID QFile::rename(pathForAssignmentScript(oldUUID), pathForAssignmentScript(assignment->getUUID())); } From c9b04443105f29af8343a1864cf327db19816db3 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 08:47:14 -0700 Subject: [PATCH 4/7] correct re-assignment of static assignments --- domain-server/src/DomainServer.cpp | 51 ++++++++++++++++-------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index d882bea1c8..003a53027e 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -344,7 +344,6 @@ const NodeSet STATICALLY_ASSIGNED_NODES = NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer << NodeType::VoxelServer << NodeType::ParticleServer << NodeType::MetavoxelServer; - void DomainServer::addNodeToNodeListAndConfirmConnection(const QByteArray& packet, const HifiSockAddr& senderSockAddr) { NodeType_t nodeType; @@ -353,34 +352,40 @@ void DomainServer::addNodeToNodeListAndConfirmConnection(const QByteArray& packe int numPreInterestBytes = parseNodeDataFromByteArray(nodeType, publicSockAddr, localSockAddr, packet, senderSockAddr); QUuid assignmentUUID = uuidFromPacketHeader(packet); - SharedAssignmentPointer matchingAssignment; + bool isStaticAssignment = _staticAssignmentHash.contains(assignmentUUID); + SharedAssignmentPointer matchingAssignment = SharedAssignmentPointer(); - if (!assignmentUUID.isNull() && (matchingAssignment = matchingStaticAssignmentForCheckIn(assignmentUUID, nodeType)) - && matchingAssignment) { - // this is an assigned node, make sure the UUID sent is for an assignment we're actually trying to give out + if (isStaticAssignment) { + // this is a static assignment, make sure the UUID sent is for an assignment we're actually trying to give out + matchingAssignment = matchingStaticAssignmentForCheckIn(assignmentUUID, nodeType); - // remove the matching assignment from the assignment queue so we don't take the next check in - // (if it exists) - removeMatchingAssignmentFromQueue(matchingAssignment); + if (matchingAssignment) { + // remove the matching assignment from the assignment queue so we don't take the next check in + // (if it exists) + removeMatchingAssignmentFromQueue(matchingAssignment); + } } else { assignmentUUID = QUuid(); } - // create a new session UUID for this node - QUuid nodeUUID = QUuid::createUuid(); - - SharedNodePointer newNode = LimitedNodeList::getInstance()->addOrUpdateNode(nodeUUID, nodeType, - publicSockAddr, localSockAddr); - - // when the newNode is created the linked data is also created - // if this was a static assignment set the UUID, set the sendingSockAddr - DomainServerNodeData* nodeData = reinterpret_cast(newNode->getLinkedData()); - - nodeData->setStaticAssignmentUUID(assignmentUUID); - nodeData->setSendingSockAddr(senderSockAddr); - - // reply back to the user with a PacketTypeDomainList - sendDomainListToNode(newNode, senderSockAddr, nodeInterestListFromPacket(packet, numPreInterestBytes)); + // make sure this was either not a static assignment or it was and we had a matching one in teh queue + if ((!isStaticAssignment && !STATICALLY_ASSIGNED_NODES.contains(nodeType)) || (isStaticAssignment && matchingAssignment)) { + // create a new session UUID for this node + QUuid nodeUUID = QUuid::createUuid(); + + SharedNodePointer newNode = LimitedNodeList::getInstance()->addOrUpdateNode(nodeUUID, nodeType, + publicSockAddr, localSockAddr); + + // when the newNode is created the linked data is also created + // if this was a static assignment set the UUID, set the sendingSockAddr + DomainServerNodeData* nodeData = reinterpret_cast(newNode->getLinkedData()); + + nodeData->setStaticAssignmentUUID(assignmentUUID); + nodeData->setSendingSockAddr(senderSockAddr); + + // reply back to the user with a PacketTypeDomainList + sendDomainListToNode(newNode, senderSockAddr, nodeInterestListFromPacket(packet, numPreInterestBytes)); + } } int DomainServer::parseNodeDataFromByteArray(NodeType_t& nodeType, HifiSockAddr& publicSockAddr, From 419e0928585dee5fe77bfbd5730527982cf7bd4d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 08:48:29 -0700 Subject: [PATCH 5/7] rename matching static method in DS --- domain-server/src/DomainServer.cpp | 4 ++-- domain-server/src/DomainServer.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 003a53027e..856078b8a9 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -357,7 +357,7 @@ void DomainServer::addNodeToNodeListAndConfirmConnection(const QByteArray& packe if (isStaticAssignment) { // this is a static assignment, make sure the UUID sent is for an assignment we're actually trying to give out - matchingAssignment = matchingStaticAssignmentForCheckIn(assignmentUUID, nodeType); + matchingAssignment = matchingQueuedAssignmentForCheckIn(assignmentUUID, nodeType); if (matchingAssignment) { // remove the matching assignment from the assignment queue so we don't take the next check in @@ -1009,7 +1009,7 @@ void DomainServer::nodeKilled(SharedNodePointer node) { } } -SharedAssignmentPointer DomainServer::matchingStaticAssignmentForCheckIn(const QUuid& checkInUUID, NodeType_t nodeType) { +SharedAssignmentPointer DomainServer::matchingQueuedAssignmentForCheckIn(const QUuid& checkInUUID, NodeType_t nodeType) { QQueue::iterator i = _assignmentQueue.begin(); while (i != _assignmentQueue.end()) { diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index 9bd10b8c60..1bc9b71064 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -70,7 +70,7 @@ private: void createStaticAssignmentsForType(Assignment::Type type, const QJsonArray& configArray); void populateDefaultStaticAssignmentsExcludingTypes(const QSet& excludedTypes); - SharedAssignmentPointer matchingStaticAssignmentForCheckIn(const QUuid& checkInUUID, NodeType_t nodeType); + SharedAssignmentPointer matchingQueuedAssignmentForCheckIn(const QUuid& checkInUUID, NodeType_t nodeType); SharedAssignmentPointer deployableAssignmentForRequest(const Assignment& requestAssignment); void removeMatchingAssignmentFromQueue(const SharedAssignmentPointer& removableAssignment); void refreshStaticAssignmentAndAddToQueue(SharedAssignmentPointer& assignment); From cc7d9863989b797c1b860b24d5d0d954184d6196 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 09:29:08 -0700 Subject: [PATCH 6/7] don't make scripts statically assigned --- domain-server/src/DomainServer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 856078b8a9..f42eb6c005 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -279,7 +279,7 @@ void DomainServer::createScriptedAssignmentsFromArray(const QJsonArray &configAr qDebug() << "URL for script is" << assignmentURL; // scripts passed on CL or via JSON are static - so they are added back to the queue if the node dies - addStaticAssignmentToAssignmentHash(scriptAssignment); + _assignmentQueue.enqueue(SharedAssignmentPointer(scriptAssignment)); } } } @@ -991,6 +991,8 @@ void DomainServer::nodeKilled(SharedNodePointer node) { } } + if (node->getType() == NodeType::Agent && n + // cleanup the connection secrets that we set up for this node (on the other nodes) foreach (const QUuid& otherNodeSessionUUID, nodeData->getSessionSecretHash().keys()) { SharedNodePointer otherNode = LimitedNodeList::getInstance()->nodeWithUUID(otherNodeSessionUUID); From 07387a132e80a37938f3dc8c07f4967d88aa40cf Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 09:31:21 -0700 Subject: [PATCH 7/7] fix broken DS build --- domain-server/src/DomainServer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index f42eb6c005..eb62dacf79 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -991,8 +991,6 @@ void DomainServer::nodeKilled(SharedNodePointer node) { } } - if (node->getType() == NodeType::Agent && n - // cleanup the connection secrets that we set up for this node (on the other nodes) foreach (const QUuid& otherNodeSessionUUID, nodeData->getSessionSecretHash().keys()) { SharedNodePointer otherNode = LimitedNodeList::getInstance()->nodeWithUUID(otherNodeSessionUUID);