bugfix: init the lock of code cache at start

This commit is contained in:
Cloud Wu
2019-07-02 23:08:54 +08:00
parent 9193035767
commit 89f487e0a4
3 changed files with 11 additions and 1 deletions

View File

@@ -1063,10 +1063,14 @@ clearcache() {
static void
init() {
SPIN_INIT(&CC);
CC.L = luaL_newstate();
}
LUALIB_API void
luaL_initcodecache(void) {
SPIN_INIT(&CC);
}
static const void *
load(const char *key) {
if (CC.L == NULL)

View File

@@ -49,6 +49,7 @@ LUAMOD_API int (luaopen_package) (lua_State *L);
#define LUA_CACHELIB
LUAMOD_API int (luaopen_cache) (lua_State *L);
LUALIB_API void (luaL_initcodecache) (void);
/* open all previous libraries */
LUALIB_API void (luaL_openlibs) (lua_State *L);

View File

@@ -132,6 +132,11 @@ main(int argc, char *argv[]) {
struct skynet_config config;
#ifdef LUA_CACHELIB
// init the lock of code cache
luaL_initcodecache();
#endif
struct lua_State *L = luaL_newstate();
luaL_openlibs(L); // link lua lib