add module signal and hack lua to support it :)

This commit is contained in:
Cloud Wu
2015-03-11 15:10:53 +08:00
parent 7ced874d7c
commit a0ffff8ad6
7 changed files with 75 additions and 3 deletions

View File

@@ -43,6 +43,17 @@
/* limit for table tag-method chains (to avoid loops) */
#define MAXTAGLOOP 2000
/* Add by skynet */
lua_State * skynet_sig_L = NULL;
LUA_API void
lua_checksig_(lua_State *L) {
if (skynet_sig_L == G(L)->mainthread) {
skynet_sig_L = NULL;
lua_pushnil(L);
lua_error(L);
}
}
/*
** Similar to 'tonumber', but does not attempt to convert strings and
@@ -935,6 +946,7 @@ void luaV_execute (lua_State *L) {
vmbreak;
}
vmcase(OP_JMP) {
lua_checksig(L);
dojump(ci, i, 0);
vmbreak;
}
@@ -987,6 +999,7 @@ void luaV_execute (lua_State *L) {
vmcase(OP_CALL) {
int b = GETARG_B(i);
int nresults = GETARG_C(i) - 1;
lua_checksig(L);
if (b != 0) L->top = ra+b; /* else previous instruction set top */
if (luaD_precall(L, ra, nresults)) { /* C function? */
if (nresults >= 0) L->top = ci->top; /* adjust results */
@@ -1001,6 +1014,7 @@ void luaV_execute (lua_State *L) {
}
vmcase(OP_TAILCALL) {
int b = GETARG_B(i);
lua_checksig(L);
if (b != 0) L->top = ra+b; /* else previous instruction set top */
lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
if (luaD_precall(L, ra, LUA_MULTRET)) /* C function? */
@@ -1111,6 +1125,7 @@ void luaV_execute (lua_State *L) {
}
vmcase(OP_TFORLOOP) {
l_tforloop:
lua_checksig(L);
if (!ttisnil(ra + 1)) { /* continue loop? */
setobjs2s(L, ra, ra + 1); /* save control variable */
ci->u.l.savedpc += GETARG_sBx(i); /* jump back */