Quellcode durchsuchen

[Project] Http_stat: Notice statfiles when creating runtime

tags/3.3
Vsevolod Stakhov vor 1 Jahr
Ursprung
Commit
7b97551741
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden
1 geänderte Dateien mit 10 neuen und 2 gelöschten Zeilen
  1. 10
    2
      src/libstat/backends/http_backend.cxx

+ 10
- 2
src/libstat/backends/http_backend.cxx Datei anzeigen

class http_backend_runtime final { class http_backend_runtime final {
public: public:
static auto create(struct rspamd_task *task, bool is_learn) -> http_backend_runtime *; 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: private:
http_backends_collection *all_backends; 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; struct upstream *selected;
private: private:
http_backend_runtime(struct rspamd_task *task, bool is_learn) : http_backend_runtime(struct rspamd_task *task, bool is_learn) :
struct rspamd_statfile_config* stcf, struct rspamd_statfile_config* stcf,
gboolean learn, gboolean learn,
gpointer ctx, gpointer ctx,
gint _id)
gint id)
{ {
auto maybe_existing = rspamd_mempool_get_variable(task->task_pool, RSPAMD_MEMPOOL_HTTP_STAT_BACKEND_RUNTIME); auto maybe_existing = rspamd_mempool_get_variable(task->task_pool, RSPAMD_MEMPOOL_HTTP_STAT_BACKEND_RUNTIME);


if (maybe_existing != nullptr) { if (maybe_existing != nullptr) {
auto real_runtime = (rspamd::stat::http::http_backend_runtime *)maybe_existing;
real_runtime->notice_statfile(id, stcf);

return maybe_existing; return maybe_existing;
} }


auto runtime = rspamd::stat::http::http_backend_runtime::create(task, learn); auto runtime = rspamd::stat::http::http_backend_runtime::create(task, learn);


if (runtime) { if (runtime) {
runtime->notice_statfile(id, stcf);
rspamd_mempool_set_variable(task->task_pool, RSPAMD_MEMPOOL_HTTP_STAT_BACKEND_RUNTIME, rspamd_mempool_set_variable(task->task_pool, RSPAMD_MEMPOOL_HTTP_STAT_BACKEND_RUNTIME,
(void *)runtime, nullptr); (void *)runtime, nullptr);
} }

Laden…
Abbrechen
Speichern