Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change to call acquire_vm_cb() in main thread #571

Merged
merged 1 commit into from
Oct 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ static int luv_thread_tostring(lua_State* L)
static void luv_thread_cb(void* varg) {
//acquire vm and get top
luv_thread_t* thd = (luv_thread_t*)varg;
lua_State* L = acquire_vm_cb();
lua_State* L = thd->args.L;
luv_ctx_t *ctx = luv_context(L);

//push lua function, thread entry
Expand Down Expand Up @@ -344,12 +344,16 @@ static int luv_new_thread(lua_State* L) {
}
thread->len = len;

thread->args.L = acquire_vm_cb();
#if LUV_UV_VERSION_GEQ(1, 26, 0)
ret = uv_thread_create_ex(&thread->handle, &options, luv_thread_cb, thread);
#else
ret = uv_thread_create(&thread->handle, luv_thread_cb, thread);
#endif
if (ret < 0) return luv_error(L, ret);
if (ret < 0) {
release_vm_cb(thread->args.L);
return luv_error(L, ret);
}

return 1;
}
Expand Down