diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-06-18 14:50:43 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-06-18 14:50:43 +0100 |
commit | 7b97551741638838332ab7566d932200830f018d (patch) | |
tree | 282844a6f8140e1f97b239fe276af87cfd547ea2 | |
parent | 655048871c3bd6ee0b8e957a2b6f127b71149bec (diff) | |
download | rspamd-7b97551741638838332ab7566d932200830f018d.tar.gz rspamd-7b97551741638838332ab7566d932200830f018d.zip |
[Project] Http_stat: Notice statfiles when creating runtime
-rw-r--r-- | src/libstat/backends/http_backend.cxx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libstat/backends/http_backend.cxx b/src/libstat/backends/http_backend.cxx index 51ac6e0d8..eaf2b1804 100644 --- a/src/libstat/backends/http_backend.cxx +++ b/src/libstat/backends/http_backend.cxx @@ -80,9 +80,13 @@ private: class http_backend_runtime final { public: static auto create(struct rspamd_task *task, bool is_learn) -> http_backend_runtime *; + /* Add a new statfile with a specific id to the list of statfiles */ + auto notice_statfile(int id, const struct rspamd_statfile_config *st) -> void { + seen_statfiles[id] = st; + } private: http_backends_collection *all_backends; - robin_hood::unordered_flat_map<int, struct rspamd_statfile *> seen_statfiles; + robin_hood::unordered_flat_map<int, const struct rspamd_statfile_config *> seen_statfiles; struct upstream *selected; private: http_backend_runtime(struct rspamd_task *task, bool is_learn) : @@ -249,17 +253,21 @@ rspamd_http_runtime(struct rspamd_task* task, struct rspamd_statfile_config* stcf, gboolean learn, gpointer ctx, - gint _id) + gint id) { auto maybe_existing = rspamd_mempool_get_variable(task->task_pool, RSPAMD_MEMPOOL_HTTP_STAT_BACKEND_RUNTIME); if (maybe_existing != nullptr) { + auto real_runtime = (rspamd::stat::http::http_backend_runtime *)maybe_existing; + real_runtime->notice_statfile(id, stcf); + return maybe_existing; } auto runtime = rspamd::stat::http::http_backend_runtime::create(task, learn); if (runtime) { + runtime->notice_statfile(id, stcf); rspamd_mempool_set_variable(task->task_pool, RSPAMD_MEMPOOL_HTTP_STAT_BACKEND_RUNTIME, (void *)runtime, nullptr); } |