Explorar o código

Limit number of userdata __gc separations at state close.

Mike Pall %!s(int64=13) %!d(string=hai) anos
pai
achega
44876ec99f
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      src/lj_state.c

+ 3 - 1
src/lj_state.c

@@ -234,6 +234,7 @@ static TValue *cpfinalize(lua_State *L, lua_CFunction dummy, void *ud)
 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. */
@@ -242,7 +243,7 @@ LUA_API void lua_close(lua_State *L)
   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;
@@ -251,6 +252,7 @@ LUA_API void lua_close(lua_State *L)
       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);