From be58347aecdd902c05327f652432c5b88ab3e2a3 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 May 2015 10:40:04 -0700 Subject: [PATCH] consider assignment completed when worker thread is gone --- assignment-client/src/AssignmentClient.cpp | 9 ++++----- libraries/networking/src/NodeList.cpp | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/assignment-client/src/AssignmentClient.cpp b/assignment-client/src/AssignmentClient.cpp index f163c57d02..fe845fca4a 100644 --- a/assignment-client/src/AssignmentClient.cpp +++ b/assignment-client/src/AssignmentClient.cpp @@ -231,15 +231,15 @@ void AssignmentClient::readPendingDatagrams() { connect(_currentAssignment.data(), &ThreadedAssignment::finished, _currentAssignment.data(), &ThreadedAssignment::deleteLater); - // once it is deleted, we take down the worker thread + // once it is deleted, we quit the worker thread connect(_currentAssignment.data(), &ThreadedAssignment::destroyed, workerThread, &QThread::quit); - // once the worker thread says it is done, we consider the assignment completed - connect(workerThread, &QThread::finished, this, &AssignmentClient::assignmentCompleted); - // have the worker thread remove itself once it is done connect(workerThread, &QThread::finished, workerThread, &QThread::deleteLater); + // once the worker thread says it is done, we consider the assignment completed + connect(workerThread, &QThread::destroyed, this, &AssignmentClient::assignmentCompleted); + _currentAssignment->moveToThread(workerThread); // move the NodeList to the thread used for the _current assignment @@ -311,7 +311,6 @@ void AssignmentClient::assignmentCompleted() { auto nodeList = DependencyManager::get(); // have us handle incoming NodeList datagrams again, and make sure our ThreadedAssignment isn't handling them - disconnect(&nodeList->getNodeSocket(), 0, _currentAssignment, 0); connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, this, &AssignmentClient::readPendingDatagrams); // reset our NodeList by switching back to unassigned and clearing the list diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index b30afb91de..5244c44eee 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -150,8 +150,9 @@ void NodeList::timePingReply(const QByteArray& packet, const SharedNodePointer& void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet) { switch (packetTypeForPacket(packet)) { case PacketTypeDomainList: { - if (_domainHandler.isConnected()) { - // only process a list from domain-server if we think we're connected + if (!_domainHandler.getSockAddr().isNull()) { + // only process a list from domain-server if we're talking to a domain + // TODO: how do we make sure this is actually the domain we want the list from (DTLS probably) processDomainServerList(packet); } break;