Browse Source

GC step does not unblock collector (when it is blocked by "stop")

Roberto Ierusalimschy 17 years ago
parent
commit
e23da9edee
1 changed files with 4 additions and 1 deletions
  1. 4 1
      lapi.c

+ 4 - 1
lapi.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lapi.c,v 2.66 2008/02/19 18:55:09 roberto Exp roberto $
+** $Id: lapi.c,v 2.67 2008/07/04 18:27:11 roberto Exp roberto $
 ** Lua API
 ** See Copyright Notice in lua.h
 */
@@ -906,6 +906,7 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
       break;
     }
     case LUA_GCSTEP: {
+      lu_mem oldts = g->GCthreshold;
       lu_mem a = (cast(lu_mem, data) << 10);
       g->GCthreshold = (a <= g->totalbytes) ? g->totalbytes - a : 0;
       while (g->GCthreshold <= g->totalbytes) {
@@ -915,6 +916,8 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
           break;
         }
       }
+      if (oldts == MAX_LUMEM)  /* collector was stopped? */
+        g->GCthreshold = oldts;  /* keep it that way */
       break;
     }
     case LUA_GCSETPAUSE: {