mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Fix EmergeThread hang on exit
This commit is contained in:
parent
3b7a445cd7
commit
206ec36c8e
@ -56,6 +56,7 @@ EmergeManager::EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef) {
|
|||||||
|
|
||||||
EmergeManager::~EmergeManager() {
|
EmergeManager::~EmergeManager() {
|
||||||
emergethread->setRun(false);
|
emergethread->setRun(false);
|
||||||
|
emergethread->qevent.signal();
|
||||||
emergethread->stop();
|
emergethread->stop();
|
||||||
|
|
||||||
delete emergethread;
|
delete emergethread;
|
||||||
@ -360,8 +361,11 @@ void *EmergeThread::Thread() {
|
|||||||
|
|
||||||
while (getRun())
|
while (getRun())
|
||||||
try {
|
try {
|
||||||
while (!emerge->popBlockEmerge(&p, &flags))
|
while (!emerge->popBlockEmerge(&p, &flags)) {
|
||||||
qevent.wait();
|
qevent.wait();
|
||||||
|
if (!getRun())
|
||||||
|
goto exit_emerge_loop;
|
||||||
|
}
|
||||||
|
|
||||||
last_tried_pos = p;
|
last_tried_pos = p;
|
||||||
if (blockpos_over_limit(p))
|
if (blockpos_over_limit(p))
|
||||||
@ -393,7 +397,7 @@ void *EmergeThread::Thread() {
|
|||||||
//envlock: usually 0ms, but can take either 30 or 400ms to acquire
|
//envlock: usually 0ms, but can take either 30 or 400ms to acquire
|
||||||
JMutexAutoLock envlock(m_server->m_env_mutex);
|
JMutexAutoLock envlock(m_server->m_env_mutex);
|
||||||
ScopeProfiler sp(g_profiler, "EmergeThread: after "
|
ScopeProfiler sp(g_profiler, "EmergeThread: after "
|
||||||
"mapgen::make_block (envlock)", SPT_AVG);
|
"Mapgen::makeChunk (envlock)", SPT_AVG);
|
||||||
|
|
||||||
map->finishBlockMake(&data, modified_blocks);
|
map->finishBlockMake(&data, modified_blocks);
|
||||||
|
|
||||||
@ -465,6 +469,7 @@ void *EmergeThread::Thread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
END_DEBUG_EXCEPTION_HANDLER(errorstream)
|
END_DEBUG_EXCEPTION_HANDLER(errorstream)
|
||||||
|
exit_emerge_loop:
|
||||||
log_deregister_thread();
|
log_deregister_thread();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user