aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_common.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-09-07 16:12:44 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-09-07 16:12:44 +0100
commit2b78f5350a903a10d03f1efde8e9de35cd41f7a1 (patch)
tree6fbcd5b1d789688c8a14f0e009aa91fa51d4834f /src/lua/lua_common.c
parentdf2389900f12cd82d1246490339ef99e62ba13a1 (diff)
downloadrspamd-2b78f5350a903a10d03f1efde8e9de35cd41f7a1.tar.gz
rspamd-2b78f5350a903a10d03f1efde8e9de35cd41f7a1.zip
[Minor] Sort lua modules and use GPtrArray instead of GList
Diffstat (limited to 'src/lua/lua_common.c')
-rw-r--r--src/lua/lua_common.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 5991af656..bafe8ea93 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -1109,25 +1109,20 @@ gboolean
rspamd_init_lua_filters(struct rspamd_config *cfg, bool force_load, bool strict)
{
struct rspamd_config **pcfg;
- GList *cur;
struct script_module *module;
lua_State *L = cfg->lua_state;
- gint err_idx;
+ gint err_idx, i;
pcfg = lua_newuserdata(L, sizeof(struct rspamd_config *));
rspamd_lua_setclass(L, "rspamd{config}", -1);
*pcfg = cfg;
lua_setglobal(L, "rspamd_config");
- cur = g_list_first(cfg->script_modules);
-
- while (cur) {
- module = cur->data;
-
+ PTR_ARRAY_FOREACH(cfg->script_modules, i, module)
+ {
if (module->path) {
if (!force_load) {
if (!rspamd_config_is_module_enabled(cfg, module->name)) {
- cur = g_list_next(cur);
continue;
}
}
@@ -1154,7 +1149,6 @@ rspamd_init_lua_filters(struct rspamd_config *cfg, bool force_load, bool strict)
return FALSE;
}
- cur = g_list_next(cur);
continue;
}
@@ -1182,7 +1176,6 @@ rspamd_init_lua_filters(struct rspamd_config *cfg, bool force_load, bool strict)
return FALSE;
}
- cur = g_list_next(cur);
continue;
}
@@ -1202,7 +1195,6 @@ rspamd_init_lua_filters(struct rspamd_config *cfg, bool force_load, bool strict)
return FALSE;
}
- cur = g_list_next(cur);
continue;
}
@@ -1215,8 +1207,6 @@ rspamd_init_lua_filters(struct rspamd_config *cfg, bool force_load, bool strict)
lua_pop(L, 1); /* Error function */
}
-
- cur = g_list_next(cur);
}
return TRUE;