]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: lua: change the GC policy
authorThierry FOURNIER <tfournier@arpalert.org>
Sun, 27 Sep 2015 20:17:19 +0000 (22:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 27 Sep 2015 20:22:37 +0000 (22:22 +0200)
The GC is run each times that an Lua function exit with an error or with a success.

src/hlua.c

index 0c8d1b128b35b5d45bf3e48fae1ef8ef9d234048..b893a47b6595e540f2c20006de5c9782f041cc2b 100644 (file)
@@ -923,9 +923,8 @@ void hlua_ctx_destroy(struct hlua *lua)
         * NOTE: maybe this action locks all the Lua threads untiml the en of
         * the garbage collection.
         */
-       if (lua_status(lua->T) == LUA_OK)
-               lua_gc(lua->T, LUA_GCCOLLECT, 0);
-       else
+       lua_gc(lua->T, LUA_GCCOLLECT, 0);
+       if (lua_status(lua->T) != LUA_OK)
                lua_gc(gL.T, LUA_GCCOLLECT, 0);
 
        lua->T = NULL;
@@ -1166,6 +1165,10 @@ timeout_reached:
                break;
        }
 
+       /* This GC permits to destroy some object when a Lua timeout strikes. */
+       if (ret != HLUA_E_AGAIN)
+               lua_gc(lua->T, LUA_GCCOLLECT, 0);
+
        switch (ret) {
        case HLUA_E_AGAIN:
                break;