]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Pass statfile id when requesting for the backend runtime
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 18 Jun 2022 13:35:55 +0000 (14:35 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 18 Jun 2022 13:35:55 +0000 (14:35 +0100)
src/libstat/backends/backends.h
src/libstat/backends/cdb_backend.cxx
src/libstat/backends/http_backend.cxx
src/libstat/backends/mmaped_file.c
src/libstat/backends/redis_backend.c
src/libstat/backends/sqlite3_backend.c
src/libstat/stat_process.c

index afb408a1a02d44901bc7201efe1d9cb2d0127089..67d61238325cde83e71006c115c5d4d3689b4650 100644 (file)
@@ -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); \
index 590cddafa9c0a56747ec634e5dc2bd23da69cf4b..d0915d2d7ca715fbe7215dc9dcf067737cb22532 100644 (file)
@@ -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;
index bd3fd1d48ac730615137c02644c6de9a70f31cd3..51ac6e0d83466a8988b6521f9453f94c2d4edb06 100644 (file)
@@ -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);
 
index 7d67fa053f930ce0ce9f1aec19e7781305eebd57..046c024fb9b3fb3a67eee196b425a4a84c0b7cca 100644 (file)
@@ -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;
 
index 6d6dc365c475a2284bae405053532b978328fec2..fa69341f1fb691d25703fb5b884eacf68e5293cf 100644 (file)
@@ -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;
index 6b1cca1738b87365646e1fff435924ba9914892c..45e51fa7b7d118788bbefb6fe613336ad5c0cd7a 100644 (file)
@@ -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;
index 6683990c06e40f0ee4bbc356c3b3a273ed0a9bf7..9e2875297f4cd9722c4979c5389bf13767d3a39d 100644 (file)
@@ -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) {