Skip to content

Commit

Permalink
ruleset: handle resume errors
Browse files Browse the repository at this point in the history
Signed-off-by: He Xian <[email protected]>
  • Loading branch information
hexian000 committed Jan 22, 2025
1 parent dc0389b commit f6da67c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ruleset/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ lua_State *aux_getthread(lua_State *restrict L)
lua_pop(L, 1);
lua_State *restrict co = lua_newthread(L);
lua_pushcfunction(co, thread_main);
const int status = aux_resume(co, NULL, 0);
const int status = aux_resume(co, L, 0);
ASSERT(status == LUA_YIELD);
UNUSED(status);
return co;
Expand Down
12 changes: 10 additions & 2 deletions src/ruleset/cfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ int cfunc_request(lua_State *restrict L)

state->request = *in_cb;
*pstate = state;
aux_resume(co, L, 6);
const int status = aux_resume(co, L, 6);
if (status != LUA_OK && status != LUA_YIELD) {
lua_xmove(co, L, 1);
return lua_error(L);
}
lua_settop(L, 1);
return 1;
}
Expand Down Expand Up @@ -232,7 +236,11 @@ int cfunc_rpcall(lua_State *restrict L)

state->rpcall = *in_cb;
*pstate = state;
aux_resume(co, L, 3);
const int status = aux_resume(co, L, 3);
if (status != LUA_OK && status != LUA_YIELD) {
lua_xmove(co, L, 1);
return lua_error(L);
}
lua_settop(L, 1);
return 1;
}
Expand Down

0 comments on commit f6da67c

Please sign in to comment.