Skip to content

Commit

Permalink
Fix join
Browse files Browse the repository at this point in the history
  • Loading branch information
javalikescript committed Nov 10, 2024
1 parent d6d30bf commit a2ab366
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,11 @@ static void luv_thread_cb(void* varg) {

static void luv_thread_notify_close_cb(uv_handle_t *handle) {
luv_thread_t *thread = handle->data;
if (thread->handle != 0)
uv_thread_join(&thread->handle);

uv_thread_t uvt = thread->handle;
if (uvt != 0) {
thread->handle = 0;
uv_thread_join(&uvt);
}
luaL_unref(thread->L, LUA_REGISTRYINDEX, thread->ref);
thread->ref = LUA_NOREF;
thread->L = NULL;
Expand Down Expand Up @@ -525,9 +527,12 @@ static int luv_thread_setpriority(lua_State* L) {

static int luv_thread_join(lua_State* L) {
luv_thread_t* tid = luv_check_thread(L, 1);
int ret = uv_thread_join(&tid->handle);
if (ret < 0) return luv_error(L, ret);
tid->handle = 0;
uv_thread_t uvt = tid->handle;
if (uvt != 0) {
tid->handle = 0;
int ret = uv_thread_join(&uvt);
if (ret < 0) return luv_error(L, ret);
}
lua_pushboolean(L, 1);
return 1;
}
Expand Down

0 comments on commit a2ab366

Please sign in to comment.