ensure no new OST creation on OctreeServer shutdown

This commit is contained in:
Stephen Birarda 2015-05-08 10:12:14 -07:00
parent bab96a7711
commit 0f71e93c7f
3 changed files with 20 additions and 5 deletions

View file

@ -1216,6 +1216,11 @@ void OctreeServer::aboutToFinish() {
qDebug() << qPrintable(_safeServerName) << "server STARTING about to finish...";
qDebug() << qPrintable(_safeServerName) << "inform Octree Inbound Packet Processor that we are shutting down...";
// we're going down - set the NodeList linkedDataCallback to NULL so we do not create any more OctreeSendThreads
// this ensures that when we forceNodeShutdown below for each node we don't get any more newly connecting nodes
auto nodeList = DependencyManager::get<NodeList>();
nodeList->linkedDataCreateCallback = NULL;
if (_octreeInboundPacketProcessor) {
_octreeInboundPacketProcessor->terminating();
}
@ -1224,7 +1229,9 @@ void OctreeServer::aboutToFinish() {
_jurisdictionSender->terminating();
}
DependencyManager::get<NodeList>()->eachNode([this](const SharedNodePointer& node) {
// force a shutdown of all of our OctreeSendThreads - at this point it has to be impossible for a
// linkedDataCreateCallback to be called for a new node
nodeList->eachNode([this](const SharedNodePointer& node) {
qDebug() << qPrintable(_safeServerName) << "server about to finish while node still connected node:" << *node;
forceNodeShutdown(node);
});

View file

@ -150,7 +150,10 @@ void NodeList::timePingReply(const QByteArray& packet, const SharedNodePointer&
void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet) {
switch (packetTypeForPacket(packet)) {
case PacketTypeDomainList: {
processDomainServerList(packet);
if (_domainHandler.isConnected()) {
// only process a list from domain-server if we think we're connected
processDomainServerList(packet);
}
break;
}
case PacketTypeDomainServerRequireDTLS: {

View file

@ -41,16 +41,21 @@ void ThreadedAssignment::setFinished(bool isFinished) {
if (_statsTimer) {
_statsTimer->stop();
}
aboutToFinish();
// stop processing datagrams from the node socket
// this ensures we won't process a domain list while we are going down
auto nodeList = DependencyManager::get<NodeList>();
disconnect(&nodeList->getNodeSocket(), 0, this, 0);
// call our virtual aboutToFinish method - this gives the ThreadedAssignment subclass a chance to cleanup
aboutToFinish();
// if we have a datagram processing thread, quit it and wait on it to make sure that
// the node socket is back on the same thread as the NodeList
if (_datagramProcessingThread) {
// tell the datagram processing thread to quit and wait until it is done, then return the node socket to the NodeList
// tell the datagram processing thread to quit and wait until it is done,
// then return the node socket to the NodeList
_datagramProcessingThread->quit();
_datagramProcessingThread->wait();