mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
bugfix: init the lock of code cache at start
This commit is contained in:
@@ -1063,10 +1063,14 @@ clearcache() {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
init() {
|
init() {
|
||||||
SPIN_INIT(&CC);
|
|
||||||
CC.L = luaL_newstate();
|
CC.L = luaL_newstate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LUALIB_API void
|
||||||
|
luaL_initcodecache(void) {
|
||||||
|
SPIN_INIT(&CC);
|
||||||
|
}
|
||||||
|
|
||||||
static const void *
|
static const void *
|
||||||
load(const char *key) {
|
load(const char *key) {
|
||||||
if (CC.L == NULL)
|
if (CC.L == NULL)
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ LUAMOD_API int (luaopen_package) (lua_State *L);
|
|||||||
|
|
||||||
#define LUA_CACHELIB
|
#define LUA_CACHELIB
|
||||||
LUAMOD_API int (luaopen_cache) (lua_State *L);
|
LUAMOD_API int (luaopen_cache) (lua_State *L);
|
||||||
|
LUALIB_API void (luaL_initcodecache) (void);
|
||||||
|
|
||||||
/* open all previous libraries */
|
/* open all previous libraries */
|
||||||
LUALIB_API void (luaL_openlibs) (lua_State *L);
|
LUALIB_API void (luaL_openlibs) (lua_State *L);
|
||||||
|
|||||||
@@ -132,6 +132,11 @@ main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
struct skynet_config config;
|
struct skynet_config config;
|
||||||
|
|
||||||
|
#ifdef LUA_CACHELIB
|
||||||
|
// init the lock of code cache
|
||||||
|
luaL_initcodecache();
|
||||||
|
#endif
|
||||||
|
|
||||||
struct lua_State *L = luaL_newstate();
|
struct lua_State *L = luaL_newstate();
|
||||||
luaL_openlibs(L); // link lua lib
|
luaL_openlibs(L); // link lua lib
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user