aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/cfg_rcl.cxx
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/libserver/cfg_rcl.cxx
parentdf2389900f12cd82d1246490339ef99e62ba13a1 (diff)
downloadrspamd-2b78f5350a903a10d03f1efde8e9de35cd41f7a1.tar.gz
rspamd-2b78f5350a903a10d03f1efde8e9de35cd41f7a1.zip
[Minor] Sort lua modules and use GPtrArray instead of GList
Diffstat (limited to 'src/libserver/cfg_rcl.cxx')
-rw-r--r--src/libserver/cfg_rcl.cxx24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/libserver/cfg_rcl.cxx b/src/libserver/cfg_rcl.cxx
index 26b799cdf..e7828ff90 100644
--- a/src/libserver/cfg_rcl.cxx
+++ b/src/libserver/cfg_rcl.cxx
@@ -920,6 +920,15 @@ rspamd_rcl_lua_handler(rspamd_mempool_t *pool, const ucl_object_t *obj,
return TRUE;
}
+static int
+rspamd_lua_mod_sort_fn(gconstpointer a, gconstpointer b)
+{
+ auto *m1 = *(const script_module **) a;
+ auto *m2 = *(const script_module **) b;
+
+ return strcmp(m1->name, m2->name);
+}
+
gboolean
rspamd_rcl_add_lua_plugins_path(struct rspamd_rcl_sections_map *sections,
struct rspamd_config *cfg,
@@ -949,18 +958,7 @@ rspamd_rcl_add_lua_plugins_path(struct rspamd_rcl_sections_map *sections,
return false;
}
- if (cfg->script_modules == nullptr) {
- cfg->script_modules = g_list_append(cfg->script_modules,
- cur_mod);
- rspamd_mempool_add_destructor(cfg->cfg_pool,
- (rspamd_mempool_destruct_t) g_list_free,
- cfg->script_modules);
- }
- else {
- cfg->script_modules = g_list_append(cfg->script_modules,
- cur_mod);
- }
-
+ g_ptr_array_add(cfg->script_modules, cur_mod);
sections->lua_modules_seen.insert(fname.string());
return true;
@@ -994,6 +992,8 @@ rspamd_rcl_add_lua_plugins_path(struct rspamd_rcl_sections_map *sections,
}
}
+ g_ptr_array_sort(cfg->script_modules, rspamd_lua_mod_sort_fn);
+
return TRUE;
}