]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Allow for use of Lua 5.5
authorBrett Neumeier <brett@neumeier.us>
Tue, 13 Jan 2026 15:03:47 +0000 (09:03 -0600)
committerBrett Neumeier <brett@neumeier.us>
Tue, 13 Jan 2026 15:03:47 +0000 (09:03 -0600)
In Lua 5.5, the signature for lua_newstate changes
(there is now an additional "seed" argument),
and the mechanism for adjusting garbage collection also changes.

I don't know whether the seed of 0 is ideal when using lua_newstate;
probably, using a random seed would be better. This is a minimal patch
that gets back to a working build.

src/lua/lua_common.c

index 2ec4d6c728ec3559054a9da1efb14c27864036f2..2d362af6dc3d69455ecb027d4715286af6ea70c7 100644 (file)
@@ -931,8 +931,12 @@ rspamd_lua_init(bool wipe_mem)
 #ifdef WITH_LUAJIT
                /* TODO: broken on luajit without GC64 */
                L = luaL_newstate();
+#else
+#if LUA_VERSION_NUM >= 505
+                L = lua_newstate(rspamd_lua_wipe_realloc, NULL, 0);
 #else
                L = lua_newstate(rspamd_lua_wipe_realloc, NULL);
+#endif
 #endif
        }
        else {
@@ -1089,8 +1093,13 @@ void rspamd_lua_start_gc(struct rspamd_config *cfg)
        lua_settop(L, 0);
        /* Set up GC */
        lua_gc(L, LUA_GCCOLLECT, 0);
+#if LUA_VERSION_NUM >= 505
+        lua_gc(L, LUA_GCPARAM, LUA_GCPSTEPMUL, cfg->lua_gc_step);
+        lua_gc(L, LUA_GCPARAM, LUA_GCPPAUSE, cfg->lua_gc_pause);
+#else
        lua_gc(L, LUA_GCSETSTEPMUL, cfg->lua_gc_step);
        lua_gc(L, LUA_GCSETPAUSE, cfg->lua_gc_pause);
+#endif
        lua_gc(L, LUA_GCRESTART, 0);
 }