From 2ba98836c27f572a4d06a43a75198a1f9dfb4548 Mon Sep 17 00:00:00 2001 From: zhaozg Date: Fri, 14 Oct 2022 16:09:32 +0800 Subject: [PATCH] fix call luv_set_thread_cb order, make it earlier --- src/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index ad95fa53..fb92c6f7 100644 --- a/src/main.c +++ b/src/main.c @@ -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); @@ -152,6 +152,7 @@ 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) { @@ -159,8 +160,6 @@ int main(int argc, char* argv[] ) { 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);