From 735497f7e152906b2f45cb3d51f1c55df866d287 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Fri, 25 Mar 2011 05:50:22 -0700 Subject: [PATCH] Fixed printing of errors from child thread's Lua State. --- src/pre_generated-llthreads.nobj.c | 13 ++++++++----- src/thread.nobj.lua | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/pre_generated-llthreads.nobj.c b/src/pre_generated-llthreads.nobj.c index a1eaf67..989e40d 100644 --- a/src/pre_generated-llthreads.nobj.c +++ b/src/pre_generated-llthreads.nobj.c @@ -743,12 +743,15 @@ static void *run_child_thread(void *arg) { this->status = lua_pcall(L, nargs, LUA_MULTRET, 1); + /* alwasy print errors here, helps with debugging bad code. */ + if(this->status != 0) { + const char *err_msg = lua_tostring(L, -1); + fprintf(stderr, "Error from thread: %s\n", err_msg); + fflush(stderr); + } + + /* joinable thread, do not destroy the child state, return it back to parent. */ if(this->is_detached == 0) { - if(this->status != 0) { - const char *err_msg = lua_tostring(L, -1); - fprintf(stderr, "Error from detached thread: %s\n", err_msg); - fflush(stderr); - } return this; } /* thread is detached, so it must clean-up the child state. */ diff --git a/src/thread.nobj.lua b/src/thread.nobj.lua index 4d78b08..c425823 100644 --- a/src/thread.nobj.lua +++ b/src/thread.nobj.lua @@ -135,12 +135,15 @@ static void *run_child_thread(void *arg) { this->status = lua_pcall(L, nargs, LUA_MULTRET, 1); + /* alwasy print errors here, helps with debugging bad code. */ + if(this->status != 0) { + const char *err_msg = lua_tostring(L, -1); + fprintf(stderr, "Error from thread: %s\n", err_msg); + fflush(stderr); + } + + /* joinable thread, do not destroy the child state, return it back to parent. */ if(this->is_detached == 0) { - if(this->status != 0) { - const char *err_msg = lua_tostring(L, -1); - fprintf(stderr, "Error from detached thread: %s\n", err_msg); - fflush(stderr); - } return this; } /* thread is detached, so it must clean-up the child state. */