aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-17 17:03:13 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-17 17:03:13 +0000
commit3cfbb45a4a84836e118992099cea233920b6f92e (patch)
tree6d3370ca6234618b4632dad1f2836f1f7597f924 /src
parentc4bc17b845c9b31633b4c745a69da46978d598b6 (diff)
downloadrspamd-3cfbb45a4a84836e118992099cea233920b6f92e.tar.gz
rspamd-3cfbb45a4a84836e118992099cea233920b6f92e.zip
Properly return count of hashes for multiple fuzzy storages
Diffstat (limited to 'src')
-rw-r--r--src/libserver/fuzzy_backend.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/libserver/fuzzy_backend.c b/src/libserver/fuzzy_backend.c
index 696c9487b..56ea187cc 100644
--- a/src/libserver/fuzzy_backend.c
+++ b/src/libserver/fuzzy_backend.c
@@ -628,8 +628,6 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend,
(gint64) time (NULL));
if (rc == SQLITE_OK) {
- backend->count++;
-
if (cmd->shingles_count > 0) {
id = sqlite3_last_insert_rowid (backend->db);
shcmd = (const struct rspamd_fuzzy_shingle_cmd *) cmd;
@@ -681,8 +679,6 @@ rspamd_fuzzy_backend_del (struct rspamd_fuzzy_backend *backend,
RSPAMD_FUZZY_BACKEND_DELETE,
cmd->digest);
- backend->count -= sqlite3_changes (backend->db);
-
rspamd_fuzzy_backend_cleanup_stmt (backend,
RSPAMD_FUZZY_BACKEND_DELETE);
@@ -863,7 +859,19 @@ rspamd_fuzzy_backend_close (struct rspamd_fuzzy_backend *backend)
gsize
rspamd_fuzzy_backend_count (struct rspamd_fuzzy_backend *backend)
{
- return backend != NULL ? backend->count : 0;
+ if (backend) {
+ if (rspamd_fuzzy_backend_run_stmt (backend, RSPAMD_FUZZY_BACKEND_COUNT)
+ == SQLITE_OK) {
+ backend->count = sqlite3_column_int64 (
+ prepared_stmts[RSPAMD_FUZZY_BACKEND_COUNT].stmt, 0);
+ }
+
+ rspamd_fuzzy_backend_cleanup_stmt (backend, RSPAMD_FUZZY_BACKEND_COUNT);
+
+ return backend->count;
+ }
+
+ return 0;
}
gsize