diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-10 15:32:50 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-10 15:32:50 -0200 |
commit | 6f207b15fb20f1c7d06224354cfdf5e32fdbba68 (patch) | |
tree | c81ec4d1d2efe14db873dbb1a589c54d4be21ae2 /lstate.c | |
parent | 3184314bf32ce146fad2e4adc302c840497d5cde (diff) | |
download | lua-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.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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 | ||
200 | static void callallgcTM (lua_State *L, void *ud) { | ||
201 | UNUSED(ud); | ||
202 | luaC_callGCTM(L); /* call GC metamethods for all udata */ | ||
203 | } | ||
204 | |||
205 | |||
200 | LUA_API void lua_close (lua_State *L) { | 206 | LUA_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 | } |