highfidelity/hifi — pull request #3100 by ZappoMan (2014-06-30 20:23:45+00:00)
Title: fix crash in SendNack on server shutdown

There have been some recent crashes in voxel server that appear to have started happening once we added nack packet support. The crash appears to happen around the time the server is shutting down, if it has some Nack packets left to be sent. The crash is represented in the following stack trace:

```
[Switching to Thread 0x7fffe3fff700 (LWP 4146)]
0x00007ffff50e9425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#0 0x00007ffff50e9425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff50ecb8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff5a3c69d in __gnu_cxx::__verbose_terminate_handler() ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff5a3a846 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff5a3a873 in std::terminate() ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff5a3b28f in __cxa_pure_virtual ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00000000004fb6aa in OctreeInboundPacketProcessor::sendNackPackets (this=
0x7fffec003880)
at /mnt/ebs1/jenkins/jobs/hifi-assignment-client/workspace/label/master/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp:220
#7 0x000000000061baa5 in ReceivedPacketProcessor::process (this=
0x7fffec003880)
at /mnt/ebs1/jenkins/jobs/hifi-assignment-client/workspace/label/master/libraries/networking/src/ReceivedPacketProcessor.cpp:50
#8 0x0000000000509169 in GenericThread::threadRoutine (this=0x7fffec003880)
at /mnt/ebs1/jenkins/jobs/hifi-assignment-client/workspace/label/master/libraries/shared/src/GenericThread.cpp:63
#9 0x00007ffff79c47a1 in QMetaObject::activate(QObject*, int, int, void**) ()
from /usr/local/Qt-5.2.0/lib/libQt5Core.so.5
#10 0x00007ffff77bd9a1 in ?? () from /usr/local/Qt-5.2.0/lib/libQt5Core.so.5
#11 0x00007ffff6527e9a in start_thread ()
from /lib/x86_64-linux-gnu/libpthread.so.0
#12 0x00007ffff51a73fd in clone () from /lib/x86_64-linux-gnu/libc.so.6
#13 0x0000000000000000 in ?? ()
A debugging session is active.
```

The problem is caused by the server object already being destructed, and so the virtual functions for determining packet type are no longer valid. The fix is to notify the nack processing thread that the server is shutting down so it doesn't continue to send nack packets.