Skip to content

Commit

Permalink
fix call luv_set_thread_cb order, make it earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaozg committed Oct 15, 2022
1 parent 4115796 commit 2ba9883
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static lua_State* vm_acquire(){
lua_pushcfunction(L, luaopen_luv);
lua_call(L, 0, 1);
lua_setfield(L, -2, "uv");

// remove package.loaded
lua_remove(L, -1);

Expand Down Expand Up @@ -152,15 +152,14 @@ int main(int argc, char* argv[] ) {
// Hooks in libuv that need to be done in main.
argv = uv_setup_args(argc, argv);

luv_set_thread_cb(vm_acquire, vm_release);
// Create the lua state.
L = vm_acquire();
if (L == NULL) {
fprintf(stderr, "luaL_newstate has failed\n");
return 1;
}

luv_set_thread_cb(vm_acquire, vm_release);

#ifdef WITH_WINSVC
// Store luvi module definition at preload.openssl
lua_pushcfunction(L, luaopen_winsvc);
Expand Down

0 comments on commit 2ba9883

Please sign in to comment.