Skip to content

Commit 5bd2aea

Browse files
committedMay 30, 2014
Fix over-poping and only push the core once
1 parent e770659 commit 5bd2aea

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed
 

‎src/script/cpp_api/s_async.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ void* AsyncWorkerThread::Thread()
262262
abort();
263263
}
264264

265+
lua_getglobal(L, "core");
266+
if (lua_isnil(L, -1)) {
267+
errorstream << "Unable to find core within async environment!";
268+
abort();
269+
}
270+
265271
// Main loop
266272
while (!StopRequested()) {
267273
// Wait for job
@@ -271,12 +277,6 @@ void* AsyncWorkerThread::Thread()
271277
continue;
272278
}
273279

274-
lua_getglobal(L, "core");
275-
if (lua_isnil(L, -1)) {
276-
errorstream << "Unable to find core within async environment!";
277-
abort();
278-
}
279-
280280
lua_getfield(L, -1, "job_processor");
281281
if (lua_isnil(L, -1)) {
282282
errorstream << "Unable to get async job processor!" << std::endl;
@@ -303,13 +303,16 @@ void* AsyncWorkerThread::Thread()
303303
toProcess.serializedResult = std::string(retval, length);
304304
}
305305

306-
// Pop core, job_processor, and retval
307-
lua_pop(L, 3);
306+
lua_pop(L, 1); // Pop retval
308307

309308
// Put job result
310309
jobDispatcher->putJobResult(toProcess);
311310
}
311+
312+
lua_pop(L, 1); // Pop core
313+
312314
log_deregister_thread();
315+
313316
return 0;
314317
}
315318

0 commit comments

Comments
 (0)
Please sign in to comment.