summaryrefslogtreecommitdiffstats
path: root/src/libstat/learn_cache
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-01 16:58:57 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-01 16:58:57 +0100
commit5f0f8b6fd6eba17c11c6bf8e16b33323d31ae8c1 (patch)
treeba4dd1995f1909597bbc2d9026c2f12e1139b853 /src/libstat/learn_cache
parenteb432059d0607201edac1ef68c436a9bd6c59f34 (diff)
downloadrspamd-5f0f8b6fd6eba17c11c6bf8e16b33323d31ae8c1.tar.gz
rspamd-5f0f8b6fd6eba17c11c6bf8e16b33323d31ae8c1.zip
Fix logging in sqlite3 modules.
Diffstat (limited to 'src/libstat/learn_cache')
-rw-r--r--src/libstat/learn_cache/sqlite3_cache.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/libstat/learn_cache/sqlite3_cache.c b/src/libstat/learn_cache/sqlite3_cache.c
index 0b2aa5ed8..745b8839c 100644
--- a/src/libstat/learn_cache/sqlite3_cache.c
+++ b/src/libstat/learn_cache/sqlite3_cache.c
@@ -164,7 +164,8 @@ rspamd_stat_cache_sqlite3_init(struct rspamd_stat_ctx *ctx,
}
if (has_sqlite_cache) {
- sqlite = rspamd_sqlite3_open_or_create (dbpath, create_tables_sql, &err);
+ sqlite = rspamd_sqlite3_open_or_create (cfg->cfg_pool,
+ dbpath, create_tables_sql, &err);
if (sqlite == NULL) {
msg_err_config ("cannot open sqlite3 cache: %e", err);
@@ -192,17 +193,18 @@ rspamd_stat_cache_sqlite3_init(struct rspamd_stat_ctx *ctx,
}
static rspamd_learn_t
-rspamd_stat_cache_sqlite3_check (const guchar *h, gsize len, gboolean is_spam,
+rspamd_stat_cache_sqlite3_check (rspamd_mempool_t *pool,
+ const guchar *h, gsize len, gboolean is_spam,
struct rspamd_stat_sqlite3_ctx *ctx)
{
gint rc, ret = RSPAMD_LEARN_OK;
gint64 flag;
- rspamd_sqlite3_run_prstmt (ctx->db, ctx->prstmt,
+ rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_START_DEF);
- rc = rspamd_sqlite3_run_prstmt (ctx->db, ctx->prstmt,
+ rc = rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_GET_LEARN, (gint64)len, h, &flag);
- rspamd_sqlite3_run_prstmt (ctx->db, ctx->prstmt,
+ rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_COMMIT);
if (rc == SQLITE_OK) {
@@ -214,11 +216,11 @@ rspamd_stat_cache_sqlite3_check (const guchar *h, gsize len, gboolean is_spam,
else {
/* Need to relearn */
flag = is_spam ? 1 : 0;
- rspamd_sqlite3_run_prstmt (ctx->db, ctx->prstmt,
+ rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_START_IM);
- rspamd_sqlite3_run_prstmt (ctx->db, ctx->prstmt,
+ rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_UPDATE_LEARN, (gint64)len, h, flag);
- rspamd_sqlite3_run_prstmt (ctx->db, ctx->prstmt,
+ rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_COMMIT);
return RSPAMD_LEARN_UNLEARN;
@@ -227,11 +229,11 @@ rspamd_stat_cache_sqlite3_check (const guchar *h, gsize len, gboolean is_spam,
else {
/* Insert result new id */
flag = is_spam ? 1 : 0;
- rspamd_sqlite3_run_prstmt (ctx->db, ctx->prstmt,
+ rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_START_IM);
- rspamd_sqlite3_run_prstmt (ctx->db, ctx->prstmt,
+ rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_ADD_LEARN, (gint64)len, h, flag);
- rspamd_sqlite3_run_prstmt (ctx->db, ctx->prstmt,
+ rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_COMMIT);
}
@@ -265,7 +267,8 @@ rspamd_stat_cache_sqlite3_process (struct rspamd_task *task,
blake2b_final (&st, out, sizeof (out));
- return rspamd_stat_cache_sqlite3_check (out, sizeof (out), is_spam, ctx);
+ return rspamd_stat_cache_sqlite3_check (task->task_pool,
+ out, sizeof (out), is_spam, ctx);
}
return RSPAMD_LEARN_OK;