aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkwolekr <mirrorisim@gmail.com>2013-02-14 19:22:43 -0500
committerkwolekr <mirrorisim@gmail.com>2013-02-25 22:58:24 -0500
commit206ec36c8e50a017636a70345b95f79feffb2446 (patch)
tree919c987ecb016c3fad4e09d90075d1387a054a97
parent3b7a445cd78c6b5ab301b5bf44e1ec54a00427f1 (diff)
downloadminetest-206ec36c8e50a017636a70345b95f79feffb2446.tar.gz
minetest-206ec36c8e50a017636a70345b95f79feffb2446.tar.bz2
minetest-206ec36c8e50a017636a70345b95f79feffb2446.zip
Fix EmergeThread hang on exit
-rw-r--r--src/emerge.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/emerge.cpp b/src/emerge.cpp
index 82867be50..e2b9e5a6c 100644
--- a/src/emerge.cpp
+++ b/src/emerge.cpp
@@ -56,6 +56,7 @@ EmergeManager::EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef) {
EmergeManager::~EmergeManager() {
emergethread->setRun(false);
+ emergethread->qevent.signal();
emergethread->stop();
delete emergethread;
@@ -360,8 +361,11 @@ void *EmergeThread::Thread() {
while (getRun())
try {
- while (!emerge->popBlockEmerge(&p, &flags))
+ while (!emerge->popBlockEmerge(&p, &flags)) {
qevent.wait();
+ if (!getRun())
+ goto exit_emerge_loop;
+ }
last_tried_pos = 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
JMutexAutoLock envlock(m_server->m_env_mutex);
ScopeProfiler sp(g_profiler, "EmergeThread: after "
- "mapgen::make_block (envlock)", SPT_AVG);
+ "Mapgen::makeChunk (envlock)", SPT_AVG);
map->finishBlockMake(&data, modified_blocks);
@@ -465,6 +469,7 @@ void *EmergeThread::Thread() {
}
END_DEBUG_EXCEPTION_HANDLER(errorstream)
+exit_emerge_loop:
log_deregister_thread();
return NULL;
}