diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-11-24 14:11:57 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-11-24 14:11:57 +0000 |
commit | c2d682793739cb332728f477abdc3848338b8d0e (patch) | |
tree | 21ba2fa570ac1a0bfef1cf95c929f0e9b204da69 | |
parent | dde5ef47920195cd394f6b682ac2655df810c920 (diff) | |
download | rspamd-c2d682793739cb332728f477abdc3848338b8d0e.tar.gz rspamd-c2d682793739cb332728f477abdc3848338b8d0e.zip |
Add more diagnostic to fuzzy errors
-rw-r--r-- | src/libserver/fuzzy_backend.c | 44 | ||||
-rw-r--r-- | src/plugins/fuzzy_check.c | 7 |
2 files changed, 42 insertions, 9 deletions
diff --git a/src/libserver/fuzzy_backend.c b/src/libserver/fuzzy_backend.c index 86902d05c..611d212c4 100644 --- a/src/libserver/fuzzy_backend.c +++ b/src/libserver/fuzzy_backend.c @@ -595,11 +595,15 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend, if (rc == SQLITE_OK) { /* We need to increase weight */ - if (rc == SQLITE_OK) { - rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE, - RSPAMD_FUZZY_BACKEND_UPDATE, - (gint64) cmd->value, - cmd->digest); + rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE, + RSPAMD_FUZZY_BACKEND_UPDATE, + (gint64) cmd->value, + cmd->digest); + if (rc != SQLITE_OK) { + msg_warn_fuzzy_backend ("cannot update hash to %d -> " + "%*xs: %s", (gint) cmd->flag, + (gint) sizeof (cmd->digest), cmd->digest, + sqlite3_errmsg (backend->db)); } } else { @@ -617,16 +621,29 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend, shcmd = (const struct rspamd_fuzzy_shingle_cmd *) cmd; for (i = 0; i < RSPAMD_SHINGLE_SIZE; i++) { - rspamd_fuzzy_backend_run_stmt (backend, TRUE, + rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE, RSPAMD_FUZZY_BACKEND_INSERT_SHINGLE, shcmd->sgl.hashes[i], i, id); msg_debug_fuzzy_backend ("add shingle %d -> %L: %L", i, shcmd->sgl.hashes[i], id); + + if (rc != SQLITE_OK) { + msg_warn_fuzzy_backend ("cannot add shingle %d -> " + "%L: %L: %s", i, + shcmd->sgl.hashes[i], + id, sqlite3_errmsg (backend->db)); + } } } } + else { + msg_warn_fuzzy_backend ("cannot add hash to %d -> " + "%*xs: %s", (gint)cmd->flag, + (gint)sizeof (cmd->digest), cmd->digest, + sqlite3_errmsg (backend->db)); + } rspamd_fuzzy_backend_cleanup_stmt (backend, RSPAMD_FUZZY_BACKEND_INSERT); @@ -638,6 +655,10 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend, RSPAMD_FUZZY_BACKEND_TRANSACTION_COMMIT); } else { + msg_warn_fuzzy_backend ("cannot commit hash to %d -> " + "%*xs: %s", (gint) cmd->flag, + (gint) sizeof (cmd->digest), cmd->digest, + sqlite3_errmsg (backend->db)); rspamd_fuzzy_backend_run_stmt (backend, TRUE, RSPAMD_FUZZY_BACKEND_TRANSACTION_ROLLBACK); } @@ -666,8 +687,19 @@ rspamd_fuzzy_backend_del (struct rspamd_fuzzy_backend *backend, if (rc == SQLITE_OK) { rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE, RSPAMD_FUZZY_BACKEND_TRANSACTION_COMMIT); + + if (rc != SQLITE_OK) { + msg_warn_fuzzy_backend ("cannot commit delete hash from %d -> " + "%*xs: %s", (gint) cmd->flag, + (gint) sizeof (cmd->digest), cmd->digest, + sqlite3_errmsg (backend->db)); + } } else { + msg_warn_fuzzy_backend ("cannot delete hash from %d -> " + "%*xs: %s", (gint) cmd->flag, + (gint) sizeof (cmd->digest), cmd->digest, + sqlite3_errmsg (backend->db)); rspamd_fuzzy_backend_run_stmt (backend, TRUE, RSPAMD_FUZZY_BACKEND_TRANSACTION_ROLLBACK); } diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 7e03009f9..be1b556c8 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -1251,9 +1251,10 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule, /* Check length of part */ if (fuzzy_module_ctx->min_bytes > part->content->len) { - msg_info_task ("<%s>, part is shorter than %d symbols, skip fuzzy " - "check", - task->message_id, fuzzy_module_ctx->min_bytes); + msg_info_task ("<%s>, part is shorter than %d bytes (%d bytes), " + "skip fuzzy check", + task->message_id, fuzzy_module_ctx->min_bytes, + part->content->len); continue; } |