]> source.dussan.org Git - rspamd.git/commitdiff
Remove old statfile_pool logic.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 17 Jan 2015 21:59:44 +0000 (21:59 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 18 Jan 2015 23:05:15 +0000 (23:05 +0000)
src/libserver/CMakeLists.txt
src/libstat/classifiers.h
src/libstat/classifiers/bayes.c
src/libstat/classifiers/classifiers.c
src/libutil/util.c
src/libutil/util.h
src/lua/lua_task.c
src/main.h

index a35d740d978da402e1d1c3a01a7140e4a1781465..93662b6b7b2427b3ec3036f28622693b22bdf733 100644 (file)
@@ -13,7 +13,6 @@ SET(LIBRSPAMDSERVERSRC
                                proxy.c
                                roll_history.c
                                spf.c
-                               statfile.c
                                symbols_cache.c
                                task.c
                                url.c
index 2c2f3344981a6923d0e0750cfb728e94438368c9..8c05bc6db2493b8bf79bbfb989df5d4c8737f00a 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "config.h"
 #include "mem_pool.h"
-#include "statfile.h"
 #include "tokenizers.h"
 #include <lua.h>
 
@@ -31,17 +30,11 @@ struct classifier {
        struct classifier_ctx * (*init_func)(rspamd_mempool_t *pool,
                struct rspamd_classifier_config *cf);
        gboolean (*classify_func)(struct classifier_ctx * ctx,
-               statfile_pool_t *pool, GTree *input, struct rspamd_task *task,
+               GTree *input, struct rspamd_task *task,
                lua_State *L);
-       gboolean (*learn_func)(struct classifier_ctx * ctx, statfile_pool_t *pool,
-               const char *symbol, GTree *input, gboolean in_class,
-               double *sum, double multiplier, GError **err);
        gboolean (*learn_spam_func)(struct classifier_ctx * ctx,
-               statfile_pool_t *pool,
                GTree *input, struct rspamd_task *task, gboolean is_spam, lua_State *L,
                GError **err);
-       GList * (*weights_func)(struct classifier_ctx * ctx, statfile_pool_t *pool,
-               GTree *input, struct rspamd_task *task);
 };
 
 /* Get classifier structure by name or return NULL if this name is not found */
@@ -51,29 +44,15 @@ struct classifier * rspamd_stat_get_classifier (const char *name);
 struct classifier_ctx * bayes_init (rspamd_mempool_t *pool,
        struct rspamd_classifier_config *cf);
 gboolean bayes_classify (struct classifier_ctx * ctx,
-       statfile_pool_t *pool,
        GTree *input,
        struct rspamd_task *task,
        lua_State *L);
-gboolean bayes_learn (struct classifier_ctx * ctx,
-       statfile_pool_t *pool,
-       const char *symbol,
-       GTree *input,
-       gboolean in_class,
-       double *sum,
-       double multiplier,
-       GError **err);
 gboolean bayes_learn_spam (struct classifier_ctx * ctx,
-       statfile_pool_t *pool,
        GTree *input,
        struct rspamd_task *task,
        gboolean is_spam,
        lua_State *L,
        GError **err);
-GList * bayes_weights (struct classifier_ctx * ctx,
-       statfile_pool_t *pool,
-       GTree *input,
-       struct rspamd_task *task);
 /* Array of all defined classifiers */
 extern struct classifier classifiers[];
 
index d2ecb340e4bd794da4275b8e823f47344f89463a..070f02008c7a7e8094ead03988ce49d4030f34c0 100644 (file)
@@ -356,122 +356,6 @@ bayes_classify (struct classifier_ctx * ctx,
        return TRUE;
 }
 
-gboolean
-bayes_learn (struct classifier_ctx * ctx,
-       statfile_pool_t *pool,
-       const char *symbol,
-       GTree *input,
-       gboolean in_class,
-       double *sum,
-       double multiplier,
-       GError **err)
-{
-       struct bayes_callback_data data;
-       gchar *value;
-       gint nodes;
-       gint minnodes;
-       struct rspamd_statfile_config *st, *sel_st = NULL;
-       stat_file_t *to_learn;
-       GList *cur;
-
-       g_assert (pool != NULL);
-       g_assert (ctx != NULL);
-
-       if (ctx->cfg->opts &&
-               (value = g_hash_table_lookup (ctx->cfg->opts, "min_tokens")) != NULL) {
-               minnodes = strtol (value, NULL, 10);
-               nodes = g_tree_nnodes (input);
-               if (nodes > FEATURE_WINDOW_SIZE) {
-                       nodes = nodes / FEATURE_WINDOW_SIZE + FEATURE_WINDOW_SIZE;
-               }
-               if (nodes < minnodes) {
-                       msg_info (
-                               "do not learn message as it has too few tokens: %d, while %d min",
-                               nodes,
-                               minnodes);
-                       *sum = 0;
-                       g_set_error (err,
-                               bayes_error_quark (),           /* error domain */
-                               1,                                  /* error code */
-                               "message contains too few tokens: %d, while min is %d",
-                               nodes, (int)minnodes);
-                       return FALSE;
-               }
-       }
-
-       data.pool = pool;
-       data.in_class = in_class;
-       data.now = time (NULL);
-       data.ctx = ctx;
-       data.processed_tokens = 0;
-       data.processed_tokens = 0;
-       if (ctx->cfg->opts &&
-               (value = g_hash_table_lookup (ctx->cfg->opts, "max_tokens")) != NULL) {
-               minnodes = rspamd_config_parse_limit (value, -1);
-               data.max_tokens = minnodes;
-       }
-       else {
-               data.max_tokens = 0;
-       }
-       cur = ctx->cfg->statfiles;
-       while (cur) {
-               /* Select statfile to learn */
-               st = cur->data;
-               if (strcmp (st->symbol, symbol) == 0) {
-                       sel_st = st;
-                       break;
-               }
-               cur = g_list_next (cur);
-       }
-       if (sel_st == NULL) {
-               g_set_error (err,
-                       bayes_error_quark (),           /* error domain */
-                       1,                              /* error code */
-                       "cannot find statfile for symbol: %s",
-                       symbol);
-               return FALSE;
-       }
-       if ((to_learn = statfile_pool_is_open (pool, sel_st->path)) == NULL) {
-               if ((to_learn =
-                       statfile_pool_open (pool, sel_st->path, sel_st->size,
-                       FALSE)) == NULL) {
-                       msg_warn ("cannot open %s", sel_st->path);
-                       if (statfile_pool_create (pool, sel_st->path, sel_st->size) == -1) {
-                               msg_err ("cannot create statfile %s", sel_st->path);
-                               g_set_error (err,
-                                       bayes_error_quark (),           /* error domain */
-                                       1,                              /* error code */
-                                       "cannot create statfile: %s",
-                                       sel_st->path);
-                               return FALSE;
-                       }
-                       if ((to_learn =
-                               statfile_pool_open (pool, sel_st->path, sel_st->size,
-                               FALSE)) == NULL) {
-                               g_set_error (err,
-                                       bayes_error_quark (),           /* error domain */
-                                       1,                              /* error code */
-                                       "cannot open statfile %s after creation",
-                                       sel_st->path);
-                               msg_err ("cannot open statfile %s after creation",
-                                       sel_st->path);
-                               return FALSE;
-                       }
-               }
-       }
-       data.file = to_learn;
-       statfile_pool_lock_file (pool, data.file);
-       g_tree_foreach (input, bayes_learn_callback, &data);
-       statfile_inc_revision (to_learn);
-       statfile_pool_unlock_file (pool, data.file);
-
-       if (sum != NULL) {
-               *sum = data.processed_tokens;
-       }
-
-       return TRUE;
-}
-
 gboolean
 bayes_learn_spam (struct classifier_ctx * ctx,
        statfile_pool_t *pool,
@@ -583,13 +467,3 @@ bayes_learn_spam (struct classifier_ctx * ctx,
 
        return TRUE;
 }
-
-GList *
-bayes_weights (struct classifier_ctx * ctx,
-       statfile_pool_t *pool,
-       GTree *input,
-       struct rspamd_task *task)
-{
-       /* This function is unimplemented with new normalizer */
-       return NULL;
-}
index a3efb53c1e308fa87e43204b9d69ba4b328dd8f9..4d78f1f81dd432ff05df464d060e47be7005b16b 100644 (file)
@@ -33,9 +33,7 @@ struct classifier classifiers[] = {
                .name = "bayes",
                .init_func = bayes_init,
                .classify_func = bayes_classify,
-               .learn_func = bayes_learn,
                .learn_spam_func = bayes_learn_spam,
-               .weights_func = bayes_weights
        }
 };
 
index b45a684551da8949086e07c0897cd60248c607aa..1b0e08b9f6a72ccb8c37b0a3e9600b586d323072 100644 (file)
@@ -27,7 +27,6 @@
 #include "util.h"
 #include "cfg_file.h"
 #include "main.h"
-#include "statfile.h"
 #include "filter.h"
 #include "message.h"
 
index bd2d069a17db06d005dc8f01c7d0d8af8113d5ba..62a28d47488b78b905b86e91a6c7c5bd506bcefc 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "config.h"
 #include "mem_pool.h"
-#include "statfile.h"
 #include "printf.h"
 #include "fstring.h"
 #include "ucl.h"
@@ -12,8 +11,6 @@
 struct rspamd_config;
 struct rspamd_main;
 struct workq;
-struct rspamd_statfile_config;
-struct rspamd_classifier_config;
 
 /**
  * Create generic socket
index 7eed0a3956a94c6211014401547d6474e3839f62..86b19827f3db4a9351f3dd832444f04f39d25a43 100644 (file)
@@ -32,7 +32,6 @@
 #include "util.h"
 #include "images.h"
 #include "cfg_file.h"
-#include "statfile.h"
 #include "tokenizers.h"
 #include "classifiers.h"
 #include "diff.h"
index de571c27f89415710dbfb5f528041061ad1b712c..741e0d3507464ce83a942caedb592453e4d0eda2 100644 (file)
@@ -13,7 +13,6 @@
 #include "libutil/logger.h"
 #include "libutil/http.h"
 #include "libutil/upstream.h"
-#include "libserver/statfile.h"
 #include "libserver/url.h"
 #include "libserver/protocol.h"
 #include "libserver/buffer.h"
@@ -110,7 +109,6 @@ struct rspamd_main {
        struct rspamd_stat *stat;                                   /**< pointer to statistics                                                  */
 
        rspamd_mempool_t *server_pool;                                  /**< server's memory pool                                                       */
-       statfile_pool_t *statfile_pool;                             /**< shared statfiles pool                                                  */
        GHashTable *workers;                                        /**< workers pool indexed by pid                    */
        rspamd_logger_t *logger;
        uid_t workers_uid;                                          /**< worker's uid running to                        */