From: Vsevolod Stakhov Date: Sun, 18 Jan 2015 23:11:14 +0000 (+0000) Subject: Remove legacy statfile pool. X-Git-Tag: 0.9.0~860 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a100148f8013329580e20697b3a2c078f62446b6;p=rspamd.git Remove legacy statfile pool. --- diff --git a/src/controller.c b/src/controller.c index 3b6436490..87a4a8452 100644 --- a/src/controller.c +++ b/src/controller.c @@ -1261,7 +1261,6 @@ rspamd_controller_handle_stat_common ( time_t ti; rspamd_mempool_stat_t mem_st; struct rspamd_classifier_config *ccf; - stat_file_t *statfile; struct rspamd_statfile_config *st; GList *cur_cl, *cur_st; struct rspamd_stat *stat, stat_copy; @@ -1334,40 +1333,7 @@ rspamd_controller_handle_stat_common ( sub = ucl_object_typed_new (UCL_ARRAY); while (cur_cl) { ccf = cur_cl->data; - cur_st = g_list_first (ccf->statfiles); - while (cur_st) { - st = cur_st->data; - if ((statfile = - statfile_pool_is_open (session->ctx->srv->statfile_pool, - st->path)) == NULL) { - statfile = statfile_pool_open (session->ctx->srv->statfile_pool, - st->path, st->size, FALSE); - } - if (statfile) { - ucl_object_t *obj = ucl_object_typed_new (UCL_OBJECT); - - used = statfile_get_used_blocks (statfile); - total = statfile_get_total_blocks (statfile); - statfile_get_revision (statfile, &rev, &ti); - ucl_object_insert_key (obj, - ucl_object_fromstring (st->symbol), "symbol", 0, false); - if (st->label != NULL) { - ucl_object_insert_key (obj, - ucl_object_fromstring (st->label), "label", 0, false); - } - ucl_object_insert_key (obj, ucl_object_fromint ( - rev), "revision", 0, false); - ucl_object_insert_key (obj, ucl_object_fromint ( - st->size), "size", 0, false); - ucl_object_insert_key (obj, ucl_object_fromint ( - used), "used", 0, false); - ucl_object_insert_key (obj, ucl_object_fromint ( - total), "total", 0, false); - - ucl_array_append (sub, obj); - } - cur_st = g_list_next (cur_st); - } + /* XXX: add statistics for the modern system */ cur_cl = g_list_next (cur_cl); } diff --git a/src/libmime/filter.c b/src/libmime/filter.c index c53bd1f1f..1a050657b 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -588,97 +588,7 @@ composites_foreach_callback (gpointer key, gpointer value, void *data) return; } -static gboolean -check_autolearn (struct statfile_autolearn_params *params, - struct rspamd_task *task) -{ - gchar *metric_name = DEFAULT_METRIC; - struct metric_result *metric_res; - GList *cur; - if (params->metric != NULL) { - metric_name = (gchar *)params->metric; - } - - /* First check threshold */ - metric_res = g_hash_table_lookup (task->results, metric_name); - if (metric_res == NULL) { - if (params->symbols == NULL && params->threshold_max > 0) { - /* For ham messages */ - return TRUE; - } - debug_task ("metric %s has no results", metric_name); - return FALSE; - } - else { - /* Process score of metric */ - if ((params->threshold_min != 0 && metric_res->score > - params->threshold_min) || - (params->threshold_max != 0 && metric_res->score < - params->threshold_max)) { - /* Now check for specific symbols */ - if (params->symbols) { - cur = params->symbols; - while (cur) { - if (g_hash_table_lookup (metric_res->symbols, - cur->data) == NULL) { - return FALSE; - } - cur = g_list_next (cur); - } - } - /* Now allow processing of actual autolearn */ - return TRUE; - } - } - - return FALSE; -} - -void -process_autolearn (struct rspamd_statfile_config *st, - struct rspamd_task *task, - GTree * tokens, - struct classifier *classifier, - gchar *filename, - struct classifier_ctx *ctx) -{ - stat_file_t *statfile; - struct rspamd_statfile_config *unused; - - if (check_autolearn (st->autolearn, task)) { - if (tokens) { - /* Take care of subject */ - tokenize_subject (task, &tokens); - msg_info ("message with id <%s> autolearned statfile '%s'", - task->message_id, - filename); - - /* Get or create statfile */ - statfile = get_statfile_by_symbol (task->worker->srv->statfile_pool, - ctx->cfg, - st->symbol, - &unused, - TRUE); - - if (statfile == NULL) { - return; - } - - classifier->learn_func (ctx, - task->worker->srv->statfile_pool, - st->symbol, - tokens, - TRUE, - NULL, - 1., - NULL); - statfile_pool_plan_invalidate (task->worker->srv->statfile_pool, - DEFAULT_STATFILE_INVALIDATE_TIME, - DEFAULT_STATFILE_INVALIDATE_JITTER); - } - } -} static gboolean composites_remove_symbols (gpointer key, gpointer value, gpointer data) @@ -815,7 +725,6 @@ classifiers_callback (gpointer value, void *arg) if (cbdata->nL != NULL) { rspamd_mutex_lock (cbdata->nL->m); cl->classifier->classify_func (ctx, - task->worker->srv->statfile_pool, tokens, task, cbdata->nL->L); @@ -824,29 +733,10 @@ classifiers_callback (gpointer value, void *arg) else { /* Non-threaded case */ cl->classifier->classify_func (ctx, - task->worker->srv->statfile_pool, tokens, task, task->cfg->lua_state); } - - /* Autolearning */ - cur = g_list_first (cl->statfiles); - while (cur) { - st = cur->data; - if (st->autolearn) { - if (check_autolearn (st->autolearn, task)) { - /* Process autolearn */ - process_autolearn (st, - task, - tokens, - cl->classifier, - st->path, - ctx); - } - } - cur = g_list_next (cur); - } } @@ -1155,7 +1045,7 @@ rspamd_learn_task_spam (struct rspamd_classifier_config *cl, task->task_pool, cl); /* Learn */ if (!cl->classifier->learn_spam_func ( - cls_ctx, task->worker->srv->statfile_pool, + cls_ctx, tokens, task, is_spam, task->cfg->lua_state, err)) { if (*err) { msg_info ("learn failed for message <%s>, learn error: %s", @@ -1177,9 +1067,6 @@ rspamd_learn_task_spam (struct rspamd_classifier_config *cl, msg_info ("learn success for message <%s>", task->message_id); - statfile_pool_plan_invalidate (task->worker->srv->statfile_pool, - DEFAULT_STATFILE_INVALIDATE_TIME, - DEFAULT_STATFILE_INVALIDATE_JITTER); return TRUE; } diff --git a/src/main.c b/src/main.c index 8b76af889..fbbc5c0f0 100644 --- a/src/main.c +++ b/src/main.c @@ -495,8 +495,7 @@ fork_worker (struct rspamd_main *rspamd, struct rspamd_worker_conf *cf) case 0: /* Update pid for logging */ rspamd_log_update_pid (cf->type, rspamd->logger); - /* Lock statfile pool if possible */ - statfile_pool_lockall (rspamd->statfile_pool); + /* Lock statfile pool if possible XXX */ /* Init PRNG after fork */ ottery_init (NULL); g_random_set_seed (ottery_rand_uint32 ()); @@ -798,36 +797,6 @@ reopen_log_handler (gpointer key, gpointer value, gpointer unused) } } -static void -preload_statfiles (struct rspamd_main *rspamd) -{ - struct rspamd_classifier_config *cf; - struct rspamd_statfile_config *st; - stat_file_t *stf; - GList *cur_cl, *cur_st; - - cur_cl = rspamd->cfg->classifiers; - while (cur_cl) { - /* Open all statfiles */ - cf = cur_cl->data; - - cur_st = cf->statfiles; - while (cur_st) { - st = cur_st->data; - stf = statfile_pool_open (rspamd->statfile_pool, - st->path, - st->size, - FALSE); - if (stf == NULL) { - msg_warn ("preload of %s from %s failed", st->symbol, st->path); - } - cur_st = g_list_next (cur_st); - } - - cur_cl = g_list_next (cur_cl); - } -} - static gboolean load_rspamd_config (struct rspamd_config *cfg, gboolean init_modules) { @@ -1351,10 +1320,6 @@ main (gint argc, gchar **argv, gchar **env) setproctitle ("main process"); - /* Init statfile pool */ - rspamd_main->statfile_pool = statfile_pool_new (rspamd_main->server_pool, - rspamd_main->cfg->mlock_statfile_pool); - /* Init lua filters */ if (!rspamd_init_lua_filters (rspamd_main->cfg)) { msg_err ("error loading lua plugins"); @@ -1386,9 +1351,6 @@ main (gint argc, gchar **argv, gchar **env) /* Flush log */ rspamd_log_flush (rspamd_main->logger); - /* Preload all statfiles */ - preload_statfiles (rspamd_main); - /* Maybe read roll history */ if (rspamd_main->cfg->history_file) { rspamd_roll_history_load (rspamd_main->history, @@ -1511,8 +1473,6 @@ main (gint argc, gchar **argv, gchar **env) msg_info ("terminating..."); - statfile_pool_delete (rspamd_main->statfile_pool); - rspamd_log_close (rspamd_main->logger); rspamd_config_free (rspamd_main->cfg);