Fix yield preemption response bug and type checking bug
This commit is contained in:
parent
82581e27cf
commit
716bbf24b4
@ -9,7 +9,8 @@ int old_mask;
|
||||
int old_count;
|
||||
|
||||
void yield_hook(lua_State *L, lua_Debug *ar) {
|
||||
lua_yield(L, 0);
|
||||
lua_pushstring(L, "_preempt");
|
||||
lua_yield(L, 1);
|
||||
}
|
||||
|
||||
void activate_preempt(lua_State *L, int interval) {
|
||||
@ -59,7 +60,7 @@ int sandboxed_resume(lua_State *L) {
|
||||
// Arguments: global environment, main function
|
||||
int sandboxed_create(lua_State *L) {
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
luaL_checktype(L, 1, LUA_TFUNCTION);
|
||||
luaL_checktype(L, 2, LUA_TFUNCTION);
|
||||
|
||||
// Put a new thread at the bottom of the stack
|
||||
lua_State *thread_state = lua_newthread(L);
|
||||
@ -69,4 +70,6 @@ int sandboxed_create(lua_State *L) {
|
||||
lua_xmove(L, thread_state, 1);
|
||||
|
||||
lua_setfenv(L, 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user