LUA_API void lua_close(lua_State *L)
{
global_State *g = G(L);
+ int i;
L = mainthread(g); /* Only the main thread can be closed. */
lj_func_closeuv(L, tvref(L->stack));
lj_gc_separateudata(g, 1); /* Separate udata which have GC metamethods. */
G2J(g)->state = LJ_TRACE_IDLE;
lj_dispatch_update(g);
#endif
- for (;;) {
+ for (i = 0; i < 10; ) {
hook_enter(g);
L->status = 0;
L->cframe = NULL;
lj_gc_separateudata(g, 1); /* Separate udata again. */
if (gcref(g->gc.mmudata) == NULL) /* Until nothing is left to do. */
break;
+ i++;
}
}
close_state(L);