aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-17 21:59:44 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-18 23:05:15 +0000
commiteb9ae27c70a0b3030e6302cc065485f798a05e82 (patch)
tree52ebdd99c677cd8c50b977bcb2cd47fa4a16cd3f /src
parent665166c376a54f52b070e891780ca6209bbaa2d1 (diff)
downloadrspamd-eb9ae27c70a0b3030e6302cc065485f798a05e82.tar.gz
rspamd-eb9ae27c70a0b3030e6302cc065485f798a05e82.zip
Remove old statfile_pool logic.
Diffstat (limited to 'src')
-rw-r--r--src/libserver/CMakeLists.txt1
-rw-r--r--src/libstat/classifiers.h23
-rw-r--r--src/libstat/classifiers/bayes.c126
-rw-r--r--src/libstat/classifiers/classifiers.c2
-rw-r--r--src/libutil/util.c1
-rw-r--r--src/libutil/util.h3
-rw-r--r--src/lua/lua_task.c1
-rw-r--r--src/main.h2
8 files changed, 1 insertions, 158 deletions
diff --git a/src/libserver/CMakeLists.txt b/src/libserver/CMakeLists.txt
index a35d740d9..93662b6b7 100644
--- a/src/libserver/CMakeLists.txt
+++ b/src/libserver/CMakeLists.txt
@@ -13,7 +13,6 @@ SET(LIBRSPAMDSERVERSRC
proxy.c
roll_history.c
spf.c
- statfile.c
symbols_cache.c
task.c
url.c
diff --git a/src/libstat/classifiers.h b/src/libstat/classifiers.h
index 2c2f33449..8c05bc6db 100644
--- a/src/libstat/classifiers.h
+++ b/src/libstat/classifiers.h
@@ -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[];
diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c
index d2ecb340e..070f02008 100644
--- a/src/libstat/classifiers/bayes.c
+++ b/src/libstat/classifiers/bayes.c
@@ -357,122 +357,6 @@ bayes_classify (struct classifier_ctx * ctx,
}
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,
GTree *input,
@@ -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;
-}
diff --git a/src/libstat/classifiers/classifiers.c b/src/libstat/classifiers/classifiers.c
index a3efb53c1..4d78f1f81 100644
--- a/src/libstat/classifiers/classifiers.c
+++ b/src/libstat/classifiers/classifiers.c
@@ -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
}
};
diff --git a/src/libutil/util.c b/src/libutil/util.c
index b45a68455..1b0e08b9f 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -27,7 +27,6 @@
#include "util.h"
#include "cfg_file.h"
#include "main.h"
-#include "statfile.h"
#include "filter.h"
#include "message.h"
diff --git a/src/libutil/util.h b/src/libutil/util.h
index bd2d069a1..62a28d474 100644
--- a/src/libutil/util.h
+++ b/src/libutil/util.h
@@ -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
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 7eed0a395..86b19827f 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -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"
diff --git a/src/main.h b/src/main.h
index de571c27f..741e0d350 100644
--- a/src/main.h
+++ b/src/main.h
@@ -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 */