diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-09 18:48:43 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-09 18:48:43 +0100 |
commit | 90f9eb98987b966a6e3465b6df5a4499ba175e6d (patch) | |
tree | 47858465e070feff3f4a041a5b201f6bb62e19a0 | |
parent | 96d20fb28f752149c17df289ec7adc2180f2ba65 (diff) | |
download | rspamd-90f9eb98987b966a6e3465b6df5a4499ba175e6d.tar.gz rspamd-90f9eb98987b966a6e3465b6df5a4499ba175e6d.zip |
Try to do something about sqlite locking.
-rw-r--r-- | src/libstat/backends/sqlite3_backend.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c index 13d82b7a3..39934d44e 100644 --- a/src/libstat/backends/sqlite3_backend.c +++ b/src/libstat/backends/sqlite3_backend.c @@ -54,7 +54,7 @@ struct rspamd_stat_sqlite3_rt { }; static const char *create_tables_sql = - "BEGIN;" + "BEGIN IMMEDIATE;" "CREATE TABLE users(" "id INTEGER PRIMARY KEY," "name TEXT," @@ -537,6 +537,11 @@ rspamd_sqlite3_process_token (struct rspamd_task *task, struct token_node_s *tok if (rspamd_sqlite3_run_prstmt (bk, RSPAMD_STAT_BACKEND_GET_TOKEN, idx, rt->user_id, rt->lang_id, &iv) == SQLITE_OK) { res->value = iv; + + /* TODO: purge empty values */ + if (iv == 0) { + return FALSE; + } } else { res->value = 0.0; @@ -628,9 +633,9 @@ rspamd_sqlite3_inc_learns (struct rspamd_task *task, gpointer runtime, g_assert (rt != NULL); bk = rt->db; - rspamd_sqlite3_run_prstmt (bk, RSPAMD_STAT_BACKEND_GET_LEARNS, &res); rspamd_sqlite3_run_prstmt (bk, RSPAMD_STAT_BACKEND_INC_LEARNS, SQLITE3_DEFAULT, SQLITE3_DEFAULT); + rspamd_sqlite3_run_prstmt (bk, RSPAMD_STAT_BACKEND_GET_LEARNS, &res); return res; } @@ -645,9 +650,9 @@ rspamd_sqlite3_dec_learns (struct rspamd_task *task, gpointer runtime, g_assert (rt != NULL); bk = rt->db; - rspamd_sqlite3_run_prstmt (bk, RSPAMD_STAT_BACKEND_GET_LEARNS, &res); rspamd_sqlite3_run_prstmt (bk, RSPAMD_STAT_BACKEND_DEC_LEARNS, SQLITE3_DEFAULT, SQLITE3_DEFAULT); + rspamd_sqlite3_run_prstmt (bk, RSPAMD_STAT_BACKEND_GET_LEARNS, &res); return res; } |