Bläddra i källkod

finalizers always called protected

Roberto Ierusalimschy 16 år sedan
förälder
incheckning
d07abcc6c7
2 ändrade filer med 10 tillägg och 16 borttagningar
  1. 8 2
      lgc.c
  2. 2 14
      lstate.c

+ 8 - 2
lgc.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lgc.c,v 2.46 2008/06/23 22:07:44 roberto Exp roberto $
+** $Id: lgc.c,v 2.47 2008/06/26 19:42:45 roberto Exp roberto $
 ** Garbage Collector
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -599,6 +599,12 @@ static Udata *udata2finalize (global_State *g) {
 }
 }
 
 
 
 
+static void dothecall (lua_State *L, void *ud) {
+  UNUSED(ud);
+  luaD_call(L, L->top - 2, 0);
+}
+
+
 static void GCTM (lua_State *L) {
 static void GCTM (lua_State *L) {
   global_State *g = G(L);
   global_State *g = G(L);
   Udata *udata = udata2finalize(g);
   Udata *udata = udata2finalize(g);
@@ -611,7 +617,7 @@ static void GCTM (lua_State *L) {
     setobj2s(L, L->top, tm);
     setobj2s(L, L->top, tm);
     setuvalue(L, L->top+1, udata);
     setuvalue(L, L->top+1, udata);
     L->top += 2;
     L->top += 2;
-    luaD_call(L, L->top - 2, 0);
+    luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0);
     L->allowhook = oldah;  /* restore hooks */
     L->allowhook = oldah;  /* restore hooks */
     g->GCthreshold = oldt;  /* restore threshold */
     g->GCthreshold = oldt;  /* restore threshold */
   }
   }

+ 2 - 14
lstate.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstate.c,v 2.46 2008/08/13 17:01:33 roberto Exp roberto $
+** $Id: lstate.c,v 2.47 2008/08/26 13:27:42 roberto Exp roberto $
 ** Global State
 ** Global State
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -199,25 +199,13 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
 }
 }
 
 
 
 
-static void callallgcTM (lua_State *L, void *ud) {
-  UNUSED(ud);
-  luaC_callAllGCTM(L);  /* call GC metamethods for all udata */
-}
-
-
 LUA_API void lua_close (lua_State *L) {
 LUA_API void lua_close (lua_State *L) {
   L = G(L)->mainthread;  /* only the main thread can be closed */
   L = G(L)->mainthread;  /* only the main thread can be closed */
   lua_lock(L);
   lua_lock(L);
   luaF_close(L, L->stack);  /* close all upvalues for this thread */
   luaF_close(L, L->stack);  /* close all upvalues for this thread */
   luaC_separateudata(L, 1);  /* separate all udata with GC metamethods */
   luaC_separateudata(L, 1);  /* separate all udata with GC metamethods */
   lua_assert(L->next == NULL);
   lua_assert(L->next == NULL);
-  L->errfunc = 0;  /* no error function during GC metamethods */
-  do {  /* repeat until no more errors */
-    L->ci = L->base_ci;
-    L->base = L->top = L->ci->base;
-    G(L)->nCcalls = 0;
-  } while (luaD_rawrunprotected(L, callallgcTM, NULL) != LUA_OK);
-  lua_assert(G(L)->tobefnz == NULL);
+  luaC_callAllGCTM(L);  /* call GC metamethods for all udata */
   luai_userstateclose(L);
   luai_userstateclose(L);
   close_state(L);
   close_state(L);
 }
 }