summaryrefslogtreecommitdiffstats
path: root/src/libstat/learn_cache
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-11 11:18:28 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-11 11:18:28 +0000
commit13371ea6841d6b9668b313aecd2e860e173085e5 (patch)
tree25460d94a77f15b785eb4949d50c6597d2097369 /src/libstat/learn_cache
parentb9dd124a65b946df04e1edc7722f024f798913b3 (diff)
downloadrspamd-13371ea6841d6b9668b313aecd2e860e173085e5.tar.gz
rspamd-13371ea6841d6b9668b313aecd2e860e173085e5.zip
Rework cache API slightly
Diffstat (limited to 'src/libstat/learn_cache')
-rw-r--r--src/libstat/learn_cache/learn_cache.h12
-rw-r--r--src/libstat/learn_cache/redis_cache.c6
-rw-r--r--src/libstat/learn_cache/sqlite3_cache.c12
3 files changed, 11 insertions, 19 deletions
diff --git a/src/libstat/learn_cache/learn_cache.h b/src/libstat/learn_cache/learn_cache.h
index 263252695..3ca5baa53 100644
--- a/src/libstat/learn_cache/learn_cache.h
+++ b/src/libstat/learn_cache/learn_cache.h
@@ -45,12 +45,10 @@ struct rspamd_stat_cache {
gpointer ctx, gboolean learn);
gint (*check)(struct rspamd_task *task,
gboolean is_spam,
- gpointer runtime,
- gpointer ctx);
+ gpointer runtime);
gint (*learn)(struct rspamd_task *task,
gboolean is_spam,
- gpointer runtime,
- gpointer ctx);
+ gpointer runtime);
void (*close) (gpointer ctx);
gpointer ctx;
};
@@ -64,12 +62,10 @@ struct rspamd_stat_cache {
gpointer ctx, gboolean learn); \
gint rspamd_stat_cache_##name##_check (struct rspamd_task *task, \
gboolean is_spam, \
- gpointer runtime, \
- gpointer ctx); \
+ gpointer runtime); \
gint rspamd_stat_cache_##name##_learn (struct rspamd_task *task, \
gboolean is_spam, \
- gpointer runtime, \
- gpointer ctx); \
+ gpointer runtime); \
void rspamd_stat_cache_##name##_close (gpointer ctx)
RSPAMD_STAT_CACHE_DEF(sqlite3);
diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c
index 9224a5f46..c24c47b6d 100644
--- a/src/libstat/learn_cache/redis_cache.c
+++ b/src/libstat/learn_cache/redis_cache.c
@@ -306,8 +306,7 @@ rspamd_stat_cache_redis_runtime (struct rspamd_task *task,
gint
rspamd_stat_cache_redis_check (struct rspamd_task *task,
gboolean is_spam,
- gpointer runtime,
- gpointer c)
+ gpointer runtime)
{
struct rspamd_redis_cache_runtime *rt = runtime;
struct timeval tv;
@@ -333,8 +332,7 @@ rspamd_stat_cache_redis_check (struct rspamd_task *task,
gint
rspamd_stat_cache_redis_learn (struct rspamd_task *task,
gboolean is_spam,
- gpointer runtime,
- gpointer c)
+ gpointer runtime)
{
struct rspamd_redis_cache_runtime *rt = runtime;
struct timeval tv;
diff --git a/src/libstat/learn_cache/sqlite3_cache.c b/src/libstat/learn_cache/sqlite3_cache.c
index 9594941ba..4bc8f0d06 100644
--- a/src/libstat/learn_cache/sqlite3_cache.c
+++ b/src/libstat/learn_cache/sqlite3_cache.c
@@ -174,16 +174,15 @@ rspamd_stat_cache_sqlite3_runtime (struct rspamd_task *task,
gpointer ctx, gboolean learn)
{
/* No need of runtime for this type of classifier */
- return NULL;
+ return ctx;
}
gint
rspamd_stat_cache_sqlite3_check (struct rspamd_task *task,
gboolean is_spam,
- gpointer runtime,
- gpointer c)
+ gpointer runtime)
{
- struct rspamd_stat_sqlite3_ctx *ctx = (struct rspamd_stat_sqlite3_ctx *)c;
+ struct rspamd_stat_sqlite3_ctx *ctx = runtime;
struct mime_text_part *part;
rspamd_cryptobox_hash_state_t st;
rspamd_ftok_t *word;
@@ -243,10 +242,9 @@ rspamd_stat_cache_sqlite3_check (struct rspamd_task *task,
gint
rspamd_stat_cache_sqlite3_learn (struct rspamd_task *task,
gboolean is_spam,
- gpointer runtime,
- gpointer c)
+ gpointer runtime)
{
- struct rspamd_stat_sqlite3_ctx *ctx = (struct rspamd_stat_sqlite3_ctx *)c;
+ struct rspamd_stat_sqlite3_ctx *ctx = runtime;
gboolean unlearn = !!(task->flags & RSPAMD_TASK_FLAG_UNLEARN);
guchar *h;
gint64 flag;