mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
gc after init snlua
This commit is contained in:
@@ -97,6 +97,25 @@ traceback (lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_report_error(lua_State *L, struct skynet_context *ctx, const char *filename, int err) {
|
||||||
|
switch (err) {
|
||||||
|
case LUA_ERRRUN:
|
||||||
|
skynet_error(ctx, "lua do [%s] error : %s", filename, lua_tostring(L,-1));
|
||||||
|
break;
|
||||||
|
case LUA_ERRMEM:
|
||||||
|
skynet_error(ctx, "lua memory error : %s",filename);
|
||||||
|
break;
|
||||||
|
case LUA_ERRERR:
|
||||||
|
skynet_error(ctx, "lua message error : %s",filename);
|
||||||
|
break;
|
||||||
|
case LUA_ERRGCMM:
|
||||||
|
skynet_error(ctx, "lua gc error : %s",filename);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
lua_pop(L,1);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
snlua_init(struct snlua *l, struct skynet_context *ctx, const char * args) {
|
snlua_init(struct snlua *l, struct skynet_context *ctx, const char * args) {
|
||||||
lua_State *L = l->L;
|
lua_State *L = l->L;
|
||||||
@@ -135,25 +154,13 @@ snlua_init(struct snlua *l, struct skynet_context *ctx, const char * args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
r = lua_pcall(L,n,0,traceback_index);
|
r = lua_pcall(L,n,0,traceback_index);
|
||||||
switch (r) {
|
if (r == LUA_OK) {
|
||||||
case LUA_OK:
|
r = lua_gc(L, LUA_GCCOLLECT, 0);
|
||||||
return 0;
|
if (r == LUA_OK) {
|
||||||
case LUA_ERRRUN:
|
return 0;
|
||||||
skynet_error(ctx, "lua do [%s] error : %s", filename, lua_tostring(L,-1));
|
}
|
||||||
break;
|
}
|
||||||
case LUA_ERRMEM:
|
_report_error(L, ctx, filename, r);
|
||||||
skynet_error(ctx, "lua memory error : %s",filename);
|
|
||||||
break;
|
|
||||||
case LUA_ERRERR:
|
|
||||||
skynet_error(ctx, "lua message error : %s",filename);
|
|
||||||
break;
|
|
||||||
case LUA_ERRGCMM:
|
|
||||||
skynet_error(ctx, "lua gc error : %s",filename);
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
lua_pop(L,1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user