aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2012-04-11 15:15:50 +0200
committerMike Pall <mike>2012-04-11 15:15:50 +0200
commit44876ec99f3a772e15aa7a8a9b5134356fc6cc16 (patch)
tree9bfd32e59d8adf0fb2008109de662cf5d7d1e214 /src
parente14b6346b4d4f91eb988c8a6046814a8707e04d5 (diff)
downloadluajit-44876ec99f3a772e15aa7a8a9b5134356fc6cc16.tar.gz
luajit-44876ec99f3a772e15aa7a8a9b5134356fc6cc16.tar.bz2
luajit-44876ec99f3a772e15aa7a8a9b5134356fc6cc16.zip
Limit number of userdata __gc separations at state close.
Diffstat (limited to 'src')
-rw-r--r--src/lj_state.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lj_state.c b/src/lj_state.c
index 711869a2..77c6df67 100644
--- a/src/lj_state.c
+++ b/src/lj_state.c
@@ -234,6 +234,7 @@ static TValue *cpfinalize(lua_State *L, lua_CFunction dummy, void *ud)
234LUA_API void lua_close(lua_State *L) 234LUA_API void lua_close(lua_State *L)
235{ 235{
236 global_State *g = G(L); 236 global_State *g = G(L);
237 int i;
237 L = mainthread(g); /* Only the main thread can be closed. */ 238 L = mainthread(g); /* Only the main thread can be closed. */
238 lj_func_closeuv(L, tvref(L->stack)); 239 lj_func_closeuv(L, tvref(L->stack));
239 lj_gc_separateudata(g, 1); /* Separate udata which have GC metamethods. */ 240 lj_gc_separateudata(g, 1); /* Separate udata which have GC metamethods. */
@@ -242,7 +243,7 @@ LUA_API void lua_close(lua_State *L)
242 G2J(g)->state = LJ_TRACE_IDLE; 243 G2J(g)->state = LJ_TRACE_IDLE;
243 lj_dispatch_update(g); 244 lj_dispatch_update(g);
244#endif 245#endif
245 for (;;) { 246 for (i = 0; i < 10; ) {
246 hook_enter(g); 247 hook_enter(g);
247 L->status = 0; 248 L->status = 0;
248 L->cframe = NULL; 249 L->cframe = NULL;
@@ -251,6 +252,7 @@ LUA_API void lua_close(lua_State *L)
251 lj_gc_separateudata(g, 1); /* Separate udata again. */ 252 lj_gc_separateudata(g, 1); /* Separate udata again. */
252 if (gcref(g->gc.mmudata) == NULL) /* Until nothing is left to do. */ 253 if (gcref(g->gc.mmudata) == NULL) /* Until nothing is left to do. */
253 break; 254 break;
255 i++;
254 } 256 }
255 } 257 }
256 close_state(L); 258 close_state(L);