aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-09 22:13:25 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-09 22:13:25 +0000
commit39bd3efaeab1a4f3236ba68126534c8d73c8f804 (patch)
tree0d26dcdd7e8ae1f4fb05d063544ee3d19ccd1478
parent29fee1b7e0e47517930541afa939a56dde09133c (diff)
downloadrspamd-39bd3efaeab1a4f3236ba68126534c8d73c8f804.tar.gz
rspamd-39bd3efaeab1a4f3236ba68126534c8d73c8f804.zip
Fix unlearning in sqlite3 cache.
-rw-r--r--src/libstat/learn_cache/sqlite3_cache.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/libstat/learn_cache/sqlite3_cache.c b/src/libstat/learn_cache/sqlite3_cache.c
index 9590d00b5..299c1ebd9 100644
--- a/src/libstat/learn_cache/sqlite3_cache.c
+++ b/src/libstat/learn_cache/sqlite3_cache.c
@@ -107,7 +107,7 @@ static struct rspamd_sqlite3_prstmt prepared_stmts[RSPAMD_STAT_CACHE_MAX] =
{
.idx = RSPAMD_STAT_CACHE_UPDATE_LEARN,
.sql = "UPDATE learns SET flag=?1 WHERE digest=?2;",
- .args = "VI",
+ .args = "IV",
.stmt = NULL,
.result = SQLITE_DONE,
.ret = ""
@@ -184,19 +184,22 @@ rspamd_stat_cache_sqlite3_check (rspamd_mempool_t *pool,
rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_COMMIT);
+
if (rc == SQLITE_OK) {
/* We have some existing record in the table */
- if ((flag && is_spam) || (!flag && !is_spam)) {
+ if (!!flag == !!is_spam) {
/* Already learned */
+
ret = RSPAMD_LEARN_INGORE;
}
else {
/* Need to relearn */
- flag = is_spam ? 1 : 0;
+ flag = !!is_spam ? 1 : 0;
+
rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_START_IM);
- rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
- RSPAMD_STAT_CACHE_UPDATE_LEARN, (gint64)len, h, flag);
+ rc = rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
+ RSPAMD_STAT_CACHE_UPDATE_LEARN, flag, (gint64)len, h);
rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_COMMIT);
@@ -205,7 +208,7 @@ rspamd_stat_cache_sqlite3_check (rspamd_mempool_t *pool,
}
else {
/* Insert result new id */
- flag = is_spam ? 1 : 0;
+ flag = !!is_spam ? 1 : 0;
rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_START_IM);
rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,