aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-05-30 19:38:11 -0400
committerShadowNinja <shadowninja@minetest.net>2014-05-30 19:38:11 -0400
commit5bd2aea663945d467744749579a1812f2e47bde7 (patch)
tree90f896296261e435519a1f0d6d26c67bcb4f5b3e /src/script
parente7706593c6cbbab97667387e7c6cdb493ec2a98d (diff)
downloadminetest-5bd2aea663945d467744749579a1812f2e47bde7.tar.gz
minetest-5bd2aea663945d467744749579a1812f2e47bde7.tar.bz2
minetest-5bd2aea663945d467744749579a1812f2e47bde7.zip
Fix over-poping and only push the core once
Diffstat (limited to 'src/script')
-rw-r--r--src/script/cpp_api/s_async.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/script/cpp_api/s_async.cpp b/src/script/cpp_api/s_async.cpp
index 0b19572c2..ef84d5037 100644
--- a/src/script/cpp_api/s_async.cpp
+++ b/src/script/cpp_api/s_async.cpp
@@ -262,6 +262,12 @@ void* AsyncWorkerThread::Thread()
abort();
}
+ lua_getglobal(L, "core");
+ if (lua_isnil(L, -1)) {
+ errorstream << "Unable to find core within async environment!";
+ abort();
+ }
+
// Main loop
while (!StopRequested()) {
// Wait for job
@@ -271,12 +277,6 @@ void* AsyncWorkerThread::Thread()
continue;
}
- lua_getglobal(L, "core");
- if (lua_isnil(L, -1)) {
- errorstream << "Unable to find core within async environment!";
- abort();
- }
-
lua_getfield(L, -1, "job_processor");
if (lua_isnil(L, -1)) {
errorstream << "Unable to get async job processor!" << std::endl;
@@ -303,13 +303,16 @@ void* AsyncWorkerThread::Thread()
toProcess.serializedResult = std::string(retval, length);
}
- // Pop core, job_processor, and retval
- lua_pop(L, 3);
+ lua_pop(L, 1); // Pop retval
// Put job result
jobDispatcher->putJobResult(toProcess);
}
+
+ lua_pop(L, 1); // Pop core
+
log_deregister_thread();
+
return 0;
}