aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lua.h2
-rw-r--r--src/thread.c13
2 files changed, 12 insertions, 3 deletions
diff --git a/src/lua.h b/src/lua.h
index 1ae8820..cfff148 100644
--- a/src/lua.h
+++ b/src/lua.h
@@ -114,6 +114,8 @@ int writer(lua_State*, const void*, size_t, void*);
#define lua_gc(A, B) lua_gc(A, B, 0)
#elif LUA_VERSION_NUM == 501
+ #define LUA_OK 0
+
#define luaL_tolstring lua_tolstring
#define lua_dump(A, B, C, D) lua_dump(A, B, C)
diff --git a/src/thread.c b/src/thread.c
index fbf5f01..f166c3f 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -203,11 +203,15 @@ int _thread_await(lua_State* L){
pthread_mutex_lock(&*info->lock);
if(info->return_count == 0) return 0;
+ lua_getglobal(L, "_locals");
+ int old_locals = lua_gettop(L);
+
+ lua_getglobal(info->L, "_stored_locals");
lua_getglobal(info->L, "_res_locals");
+ luaI_jointable(info->L);
luaI_deepcopy(info->L, L, SKIP_LOCALS | STRIP_GC);
- env_table(L, 0);
+ //env_table(L, 0);
- luaI_jointable(L);
lua_setglobal(L, "_locals");
lua_getglobal(info->L, "_return_table");
@@ -219,7 +223,7 @@ int _thread_await(lua_State* L){
luaI_deepcopy(info->L, L, STRIP_GC);
}
- lua_pushnil(L);
+ lua_pushvalue(L, old_locals);
lua_setglobal(L, "_locals");
pthread_mutex_unlock(&*info->lock);
@@ -300,6 +304,9 @@ int l_async(lua_State* oL){
luaI_copyvars(oL, L);
luaL_openlibs(L);
+ lua_getglobal(L, "_locals");
+ lua_setglobal(L, "_stored_locals");
+
struct thread_info* args = calloc(1, sizeof * args);
args->L = L;
args->lock = malloc(sizeof * args->lock);