aboutsummaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-02-10 15:32:50 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-02-10 15:32:50 -0200
commit6f207b15fb20f1c7d06224354cfdf5e32fdbba68 (patch)
treec81ec4d1d2efe14db873dbb1a589c54d4be21ae2 /lstate.c
parent3184314bf32ce146fad2e4adc302c840497d5cde (diff)
downloadlua-6f207b15fb20f1c7d06224354cfdf5e32fdbba68.tar.gz
lua-6f207b15fb20f1c7d06224354cfdf5e32fdbba68.tar.bz2
lua-6f207b15fb20f1c7d06224354cfdf5e32fdbba68.zip
resist errors in finalizers during lua_close
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lstate.c b/lstate.c
index 2744a5de..a71a8abe 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 1.117 2002/12/04 17:38:31 roberto Exp roberto $ 2** $Id: lstate.c,v 1.118 2002/12/19 13:21:08 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -197,10 +197,18 @@ LUA_API lua_State *lua_open (void) {
197} 197}
198 198
199 199
200static void callallgcTM (lua_State *L, void *ud) {
201 UNUSED(ud);
202 luaC_callGCTM(L); /* call GC metamethods for all udata */
203}
204
205
200LUA_API void lua_close (lua_State *L) { 206LUA_API void lua_close (lua_State *L) {
201 lua_lock(L); 207 lua_lock(L);
202 L = G(L)->mainthread; /* only the main thread can be closed */ 208 L = G(L)->mainthread; /* only the main thread can be closed */
203 luaC_callallgcTM(L); /* call GC tag methods for all udata */ 209 luaC_separateudata(L); /* separate udata that have GC metamethods */
210 /* repeat until no more errors */
211 while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0) /* skip */;
204 lua_assert(G(L)->tmudata == NULL); 212 lua_assert(G(L)->tmudata == NULL);
205 close_state(L); 213 close_state(L);
206} 214}