aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-06-18 14:35:55 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-06-18 14:35:55 +0100
commit655048871c3bd6ee0b8e957a2b6f127b71149bec (patch)
tree6230fb73d3e5d2c35f1156cd321dc7e1689c5f4f
parent6d1ccd4aeec5509c9be5d17da376aa3cbe282969 (diff)
downloadrspamd-655048871c3bd6ee0b8e957a2b6f127b71149bec.tar.gz
rspamd-655048871c3bd6ee0b8e957a2b6f127b71149bec.zip
[Minor] Pass statfile id when requesting for the backend runtime
-rw-r--r--src/libstat/backends/backends.h6
-rw-r--r--src/libstat/backends/cdb_backend.cxx3
-rw-r--r--src/libstat/backends/http_backend.cxx7
-rw-r--r--src/libstat/backends/mmaped_file.c7
-rw-r--r--src/libstat/backends/redis_backend.c2
-rw-r--r--src/libstat/backends/sqlite3_backend.c2
-rw-r--r--src/libstat/stat_process.c4
7 files changed, 18 insertions, 13 deletions
diff --git a/src/libstat/backends/backends.h b/src/libstat/backends/backends.h
index afb408a1a..67d612383 100644
--- a/src/libstat/backends/backends.h
+++ b/src/libstat/backends/backends.h
@@ -42,7 +42,9 @@ struct rspamd_stat_backend {
struct rspamd_statfile *st);
gpointer (*runtime) (struct rspamd_task *task,
- struct rspamd_statfile_config *stcf, gboolean learn, gpointer ctx);
+ struct rspamd_statfile_config *stcf,
+ gboolean learn, gpointer ctx,
+ gint id);
gboolean (*process_tokens) (struct rspamd_task *task, GPtrArray *tokens,
gint id,
@@ -81,7 +83,7 @@ struct rspamd_stat_backend {
struct rspamd_config *cfg, struct rspamd_statfile *st); \
gpointer rspamd_##name##_runtime (struct rspamd_task *task, \
struct rspamd_statfile_config *stcf, \
- gboolean learn, gpointer ctx); \
+ gboolean learn, gpointer ctx, gint id); \
gboolean rspamd_##name##_process_tokens (struct rspamd_task *task, \
GPtrArray *tokens, gint id, \
gpointer runtime); \
diff --git a/src/libstat/backends/cdb_backend.cxx b/src/libstat/backends/cdb_backend.cxx
index 590cddafa..d0915d2d7 100644
--- a/src/libstat/backends/cdb_backend.cxx
+++ b/src/libstat/backends/cdb_backend.cxx
@@ -367,7 +367,8 @@ gpointer
rspamd_cdb_runtime(struct rspamd_task* task,
struct rspamd_statfile_config* stcf,
gboolean learn,
- gpointer ctx)
+ gpointer ctx,
+ gint _id)
{
/* In CDB we don't have any dynamic stuff */
return ctx;
diff --git a/src/libstat/backends/http_backend.cxx b/src/libstat/backends/http_backend.cxx
index bd3fd1d48..51ac6e0d8 100644
--- a/src/libstat/backends/http_backend.cxx
+++ b/src/libstat/backends/http_backend.cxx
@@ -246,9 +246,10 @@ rspamd_http_init(struct rspamd_stat_ctx* ctx,
}
gpointer
rspamd_http_runtime(struct rspamd_task* task,
- struct rspamd_statfile_config* stcf,
- gboolean learn,
- gpointer ctx)
+ struct rspamd_statfile_config* stcf,
+ gboolean learn,
+ gpointer ctx,
+ gint _id)
{
auto maybe_existing = rspamd_mempool_get_variable(task->task_pool, RSPAMD_MEMPOOL_HTTP_STAT_BACKEND_RUNTIME);
diff --git a/src/libstat/backends/mmaped_file.c b/src/libstat/backends/mmaped_file.c
index 7d67fa053..046c024fb 100644
--- a/src/libstat/backends/mmaped_file.c
+++ b/src/libstat/backends/mmaped_file.c
@@ -940,9 +940,10 @@ rspamd_mmaped_file_close (gpointer p)
gpointer
rspamd_mmaped_file_runtime (struct rspamd_task *task,
- struct rspamd_statfile_config *stcf,
- gboolean learn,
- gpointer p)
+ struct rspamd_statfile_config *stcf,
+ gboolean learn,
+ gpointer p,
+ gint _id)
{
rspamd_mmaped_file_t *mf = p;
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c
index 6d6dc365c..fa69341f1 100644
--- a/src/libstat/backends/redis_backend.c
+++ b/src/libstat/backends/redis_backend.c
@@ -1650,7 +1650,7 @@ rspamd_stat_redis_on_connect(const struct redisAsyncContext *ac, int status)
gpointer
rspamd_redis_runtime (struct rspamd_task *task,
struct rspamd_statfile_config *stcf,
- gboolean learn, gpointer c)
+ gboolean learn, gpointer c, gint _id)
{
struct redis_stat_ctx *ctx = REDIS_CTX (c);
struct redis_stat_runtime *rt;
diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c
index 6b1cca173..45e51fa7b 100644
--- a/src/libstat/backends/sqlite3_backend.c
+++ b/src/libstat/backends/sqlite3_backend.c
@@ -661,7 +661,7 @@ rspamd_sqlite3_close (gpointer p)
gpointer
rspamd_sqlite3_runtime (struct rspamd_task *task,
- struct rspamd_statfile_config *stcf, gboolean learn, gpointer p)
+ struct rspamd_statfile_config *stcf, gboolean learn, gpointer p, gint _id)
{
struct rspamd_stat_sqlite3_rt *rt = NULL;
struct rspamd_stat_sqlite3_db *bk = p;
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c
index 6683990c0..9e2875297 100644
--- a/src/libstat/stat_process.c
+++ b/src/libstat/stat_process.c
@@ -328,7 +328,7 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx,
continue;
}
- bk_run = st->backend->runtime (task, st->stcf, is_learn, st->bkcf);
+ bk_run = st->backend->runtime (task, st->stcf, is_learn, st->bkcf, i);
if (bk_run == NULL) {
msg_err_task ("cannot init backend %s for statfile %s",
@@ -1204,7 +1204,7 @@ rspamd_stat_statistics (struct rspamd_task *task,
id = g_array_index (cl->statfiles_ids, gint, j);
st = g_ptr_array_index (st_ctx->statfiles, id);
backend_runtime = st->backend->runtime (task, st->stcf, FALSE,
- st->bkcf);
+ st->bkcf, id);
elt = st->backend->get_stat (backend_runtime, st->bkcf);
if (elt && ucl_object_type (elt) == UCL_OBJECT) {