summaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-12-29 16:00:23 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-12-29 16:00:23 -0200
commit868ff40339fc72b7bf3c916afcdc2a992398346c (patch)
tree86864c97d7b1e7620a8c09e43e40cd7d6d3a5f89 /lapi.c
parentaa6faa6331e3e5e326bf5830474ffd9b04425678 (diff)
downloadlua-868ff40339fc72b7bf3c916afcdc2a992398346c.tar.gz
lua-868ff40339fc72b7bf3c916afcdc2a992398346c.tar.bz2
lua-868ff40339fc72b7bf3c916afcdc2a992398346c.zip
full collection does not restart collector + avoid changing GC
state if an error happens in a step
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/lapi.c b/lapi.c
index 73cf1108..9b824577 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.142 2010/12/20 18:17:46 roberto Exp roberto $ 2** $Id: lapi.c,v 2.143 2010/12/20 19:40:07 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -969,7 +969,6 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
969 break; 969 break;
970 } 970 }
971 case LUA_GCCOLLECT: { 971 case LUA_GCCOLLECT: {
972 g->gcrunning = 1; /* restart collector if stopped ?? */
973 luaC_fullgc(L, 0); 972 luaC_fullgc(L, 0);
974 break; 973 break;
975 } 974 }
@@ -983,22 +982,19 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
983 break; 982 break;
984 } 983 }
985 case LUA_GCSTEP: { 984 case LUA_GCSTEP: {
986 int running = g->gcrunning;
987 g->gcrunning = 1; /* allow steps */
988 if (g->gckind == KGC_GEN) { /* generational mode? */ 985 if (g->gckind == KGC_GEN) { /* generational mode? */
989 res = (g->lastmajormem == 0); /* 1 if will do major collection */ 986 res = (g->lastmajormem == 0); /* 1 if will do major collection */
990 luaC_step(L); /* do a single step */ 987 luaC_forcestep(L); /* do a single step */
991 } 988 }
992 else { 989 else {
993 while (data-- >= 0) { 990 while (data-- >= 0) {
994 luaC_step(L); 991 luaC_forcestep(L);
995 if (g->gcstate == GCSpause) { /* end of cycle? */ 992 if (g->gcstate == GCSpause) { /* end of cycle? */
996 res = 1; /* signal it */ 993 res = 1; /* signal it */
997 break; 994 break;
998 } 995 }
999 } 996 }
1000 } 997 }
1001 g->gcrunning = running; /* restore previous state */
1002 break; 998 break;
1003 } 999 }
1004 case LUA_GCSETPAUSE: { 1000 case LUA_GCSETPAUSE: {