aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/cfg_file.h1
-rw-r--r--src/libserver/cfg_utils.c3
-rw-r--r--src/libserver/composites.c15
3 files changed, 14 insertions, 5 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 75b404530..c583766c4 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -380,6 +380,7 @@ struct rspamd_config {
gchar * checksum; /**< real checksum of config file */
gchar * dump_checksum; /**< dump checksum of config file */
gpointer lua_state; /**< pointer to lua state */
+ gpointer lua_thread_pool; /**< pointer to lua thread (coroutine) pool */
gchar * rrd_file; /**< rrd file to store statistics */
gchar * history_file; /**< file to save rolling history */
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index b7b9dfdee..016556912 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -20,6 +20,7 @@
#include "uthash_strcase.h"
#include "filter.h"
#include "lua/lua_common.h"
+#include "lua/lua_thread_pool.h"
#include "map.h"
#include "map_helpers.h"
#include "map_private.h"
@@ -175,6 +176,7 @@ rspamd_config_new (enum rspamd_config_init_flags flags)
if (!(flags & RSPAMD_CONFIG_INIT_SKIP_LUA)) {
cfg->lua_state = rspamd_lua_init ();
cfg->own_lua_state = TRUE;
+ cfg->lua_thread_pool = lua_thread_pool_new (cfg->lua_state);
}
cfg->cache = rspamd_symbols_cache_new (cfg);
@@ -259,6 +261,7 @@ rspamd_config_free (struct rspamd_config *cfg)
g_ptr_array_free (cfg->c_modules, TRUE);
if (cfg->lua_state && cfg->own_lua_state) {
+ lua_thread_pool_free (cfg->lua_thread_pool);
lua_close (cfg->lua_state);
}
REF_RELEASE (cfg->libs_ctx);
diff --git a/src/libserver/composites.c b/src/libserver/composites.c
index 8f3cb179d..83f3a35d4 100644
--- a/src/libserver/composites.c
+++ b/src/libserver/composites.c
@@ -66,7 +66,7 @@ struct symbol_remove_data {
static rspamd_expression_atom_t * rspamd_composite_expr_parse (const gchar *line, gsize len,
rspamd_mempool_t *pool, gpointer ud, GError **err);
-static gdouble rspamd_composite_expr_process (gpointer input, rspamd_expression_atom_t *atom);
+static gdouble rspamd_composite_expr_process (struct rspamd_expr_process_data *process_data, rspamd_expression_atom_t *atom);
static gint rspamd_composite_expr_priority (rspamd_expression_atom_t *atom);
static void rspamd_composite_expr_destroy (rspamd_expression_atom_t *atom);
static void composites_foreach_callback (gpointer key, gpointer value, void *data);
@@ -173,9 +173,9 @@ rspamd_composite_process_single_symbol (struct composites_data *cd,
}
static gdouble
-rspamd_composite_expr_process (gpointer input, rspamd_expression_atom_t *atom)
+rspamd_composite_expr_process (struct rspamd_expr_process_data *process_data, rspamd_expression_atom_t *atom)
{
- struct composites_data *cd = (struct composites_data *)input;
+ struct composites_data *cd = process_data->cd;
const gchar *beg = atom->data, *sym = NULL;
gchar t;
struct symbol_remove_data *rd, *nrd;
@@ -344,8 +344,13 @@ composites_foreach_callback (gpointer key, gpointer value, void *data)
return;
}
- rc = rspamd_process_expression (comp->expr,
- RSPAMD_EXPRESSION_FLAG_NOOPT, cd);
+ struct rspamd_expr_process_data process_data;
+ memset (&process_data, 0, sizeof process_data);
+
+ process_data.flags = RSPAMD_EXPRESSION_FLAG_NOOPT;
+ process_data.cd = cd;
+
+ rc = rspamd_process_expression (comp->expr, &process_data);
/* Checked bit */
setbit (cd->checked, comp->id * 2);