Ensure running __gc of userdata created in __gc at state close.

This commit is contained in:
Mike Pall 2012-04-11 12:08:09 +02:00
parent d621a6ccc2
commit e14b6346b4

View File

@ -242,12 +242,17 @@ LUA_API void lua_close(lua_State *L)
G2J(g)->state = LJ_TRACE_IDLE;
lj_dispatch_update(g);
#endif
do {
for (;;) {
hook_enter(g);
L->status = 0;
L->cframe = NULL;
L->base = L->top = tvref(L->stack) + 1;
} while (lj_vm_cpcall(L, NULL, NULL, cpfinalize) != 0);
if (lj_vm_cpcall(L, NULL, NULL, cpfinalize) == 0) {
lj_gc_separateudata(g, 1); /* Separate udata again. */
if (gcref(g->gc.mmudata) == NULL) /* Until nothing is left to do. */
break;
}
}
close_state(L);
}