Fix emerge thread not cleaning up emerge queue on shutdown
authorsapier <Sapier at GMX dot net>
Sun, 4 Jan 2015 00:01:30 +0000 (01:01 +0100)
committersapier <Sapier at GMX dot net>
Wed, 7 Jan 2015 11:19:48 +0000 (12:19 +0100)
src/emerge.cpp

index 8d818612618e17aeefa8f0b0ba2ec1ec3020819c..e81793ff8b5a34d9dc1b7b1ed1ca635eaab0aa44 100644 (file)
@@ -580,6 +580,23 @@ void *EmergeThread::Thread()
                m_server->setAsyncFatalError(err.str());
        }
 
+       {
+               JMutexAutoLock queuelock(emerge->queuemutex);
+               while (!blockqueue.empty())
+               {
+                       v3s16 p = blockqueue.front();
+                       blockqueue.pop();
+
+                       std::map<v3s16, BlockEmergeData *>::iterator iter;
+                       iter = emerge->blocks_enqueued.find(p);
+                       if (iter == emerge->blocks_enqueued.end())
+                               continue; //uh oh, queue and map out of sync!!
+
+                       BlockEmergeData *bedata = iter->second;
+                       delete bedata;
+               }
+       }
+
        END_DEBUG_EXCEPTION_HANDLER(errorstream)
        log_deregister_thread();
        return NULL;