diff --git a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp index 76a6845342..a228b87491 100644 --- a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp +++ b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp @@ -28,7 +28,8 @@ OctreeInboundPacketProcessor::OctreeInboundPacketProcessor(OctreeServer* myServe _totalLockWaitTime(0), _totalElementsInPacket(0), _totalPackets(0), - _lastNackTime(usecTimestampNow()) + _lastNackTime(usecTimestampNow()), + _shuttingDown(false) { } @@ -72,6 +73,10 @@ void OctreeInboundPacketProcessor::midProcess() { } void OctreeInboundPacketProcessor::processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet) { + if (_shuttingDown) { + qDebug() << "OctreeInboundPacketProcessor::processPacket() while shutting down... ignoring incoming packet"; + return; + } bool debugProcessPacket = _myServer->wantsVerboseDebug(); @@ -182,8 +187,13 @@ void OctreeInboundPacketProcessor::trackInboundPacket(const QUuid& nodeUUID, uns } int OctreeInboundPacketProcessor::sendNackPackets() { - int packetsSent = 0; + + if (_shuttingDown) { + qDebug() << "OctreeInboundPacketProcessor::sendNackPackets() while shutting down... ignore"; + return packetsSent; + } + char packet[MAX_PACKET_SIZE]; NodeToSenderStatsMapIterator i = _singleSenderStats.begin(); @@ -241,6 +251,8 @@ int OctreeInboundPacketProcessor::sendNackPackets() { // send it NodeList::getInstance()->writeUnverifiedDatagram(packet, dataAt - packet, destinationNode); packetsSent++; + + qDebug() << "NACK Sent back to editor/client... destinationNode=" << nodeUUID; } i++; } diff --git a/assignment-client/src/octree/OctreeInboundPacketProcessor.h b/assignment-client/src/octree/OctreeInboundPacketProcessor.h index 46a57205cb..e09696a5fd 100644 --- a/assignment-client/src/octree/OctreeInboundPacketProcessor.h +++ b/assignment-client/src/octree/OctreeInboundPacketProcessor.h @@ -73,6 +73,8 @@ public: NodeToSenderStatsMap& getSingleSenderStats() { return _singleSenderStats; } + void shuttingDown() { _shuttingDown = true;} + protected: virtual void processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet); @@ -100,5 +102,6 @@ private: NodeToSenderStatsMap _singleSenderStats; quint64 _lastNackTime; + bool _shuttingDown; }; #endif // hifi_OctreeInboundPacketProcessor_h diff --git a/assignment-client/src/octree/OctreeServer.cpp b/assignment-client/src/octree/OctreeServer.cpp index 48c8674c03..23719b86cf 100644 --- a/assignment-client/src/octree/OctreeServer.cpp +++ b/assignment-client/src/octree/OctreeServer.cpp @@ -1097,6 +1097,8 @@ void OctreeServer::forceNodeShutdown(SharedNodePointer node) { void OctreeServer::aboutToFinish() { qDebug() << qPrintable(_safeServerName) << "server STARTING about to finish..."; + qDebug() << qPrintable(_safeServerName) << "inform Octree Inbound Packet Processor that we are shutting down..."; + _octreeInboundPacketProcessor->shuttingDown(); foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { qDebug() << qPrintable(_safeServerName) << "server about to finish while node still connected node:" << *node; forceNodeShutdown(node);