diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-06-23 16:07:00 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-06-23 16:07:00 +0100 |
commit | 0e09a5486513847905fb059185a7c5a32f50ead9 (patch) | |
tree | cc812dadbb38b3b264a106807a166f9c3bdcacd4 /src/libserver/fuzzy_backend.c | |
parent | 8dc67975d826c02e2757ff8e3e758b1839edb044 (diff) | |
download | rspamd-0e09a5486513847905fb059185a7c5a32f50ead9.tar.gz rspamd-0e09a5486513847905fb059185a7c5a32f50ead9.zip |
[Revert] Revert flags changes in fuzzy check
Diffstat (limited to 'src/libserver/fuzzy_backend.c')
-rw-r--r-- | src/libserver/fuzzy_backend.c | 73 |
1 files changed, 11 insertions, 62 deletions
diff --git a/src/libserver/fuzzy_backend.c b/src/libserver/fuzzy_backend.c index 5a22377bb..a45d7c6a7 100644 --- a/src/libserver/fuzzy_backend.c +++ b/src/libserver/fuzzy_backend.c @@ -32,7 +32,6 @@ struct rspamd_fuzzy_backend { static const gdouble sql_sleep_time = 0.1; static const guint max_retries = 10; -static const guint32 flags_mask = (1U << 31); #define msg_err_fuzzy_backend(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \ backend->pool->tag.tagname, backend->pool->tag.uid, \ @@ -527,10 +526,6 @@ rspamd_fuzzy_backend_check (struct rspamd_fuzzy_backend *backend, rep.prob = 1.0; rep.flag = sqlite3_column_int ( prepared_stmts[RSPAMD_FUZZY_BACKEND_CHECK].stmt, 2); - - if (!(rep.flag & flags_mask) && rep.flag > 0) { - rep.flag = (1U << (rep.flag - 1)) | flags_mask; - } } } else if (cmd->shingles_count > 0) { @@ -614,10 +609,6 @@ rspamd_fuzzy_backend_check (struct rspamd_fuzzy_backend *backend, rep.flag = sqlite3_column_int ( prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt, 3); - - if (!(rep.flag & flags_mask) && rep.flag > 0) { - rep.flag = (1U << (rep.flag - 1)) | flags_mask; - } } } } @@ -672,11 +663,6 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend, return FALSE; } - if (cmd->flag > 31 || cmd->flag == 0) { - msg_err_fuzzy_backend ("flag more than 31 is no longer supported"); - return FALSE; - } - rc = rspamd_fuzzy_backend_run_stmt (backend, FALSE, RSPAMD_FUZZY_BACKEND_CHECK, cmd->digest); @@ -688,7 +674,7 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend, 2); rspamd_fuzzy_backend_cleanup_stmt (backend, RSPAMD_FUZZY_BACKEND_CHECK); - if (flag & (1U << (cmd->flag - 1))) { + if (flag == cmd->flag) { /* We need to increase weight */ rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE, RSPAMD_FUZZY_BACKEND_UPDATE, @@ -703,26 +689,11 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend, } else { /* We need to relearn actually */ - if (flag & flags_mask) { - /* This is already new format */ - flag |= (1U << (cmd->flag - 1)); - } - else { - /* Convert to the new format */ - if (flag > 31 || flag == 0) { - msg_warn_fuzzy_backend ("storage had flag more than 31, remove " - "it"); - flag = cmd->flag | flags_mask; - } - else { - flag = (1U << (flag - 1)) | (1U << (cmd->flag - 1)) | flags_mask; - } - } rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE, RSPAMD_FUZZY_BACKEND_UPDATE_FLAG, (gint64) cmd->value, - (gint64) flag, + (gint64) cmd->flag, cmd->digest); if (rc != SQLITE_OK) { @@ -737,7 +708,7 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend, rspamd_fuzzy_backend_cleanup_stmt (backend, RSPAMD_FUZZY_BACKEND_CHECK); rc = rspamd_fuzzy_backend_run_stmt (backend, FALSE, RSPAMD_FUZZY_BACKEND_INSERT, - (gint) (1U << (cmd->flag - 1)), + (gint) cmd->flag, cmd->digest, (gint64) cmd->value); @@ -847,36 +818,14 @@ rspamd_fuzzy_backend_del (struct rspamd_fuzzy_backend *backend, 2); rspamd_fuzzy_backend_cleanup_stmt (backend, RSPAMD_FUZZY_BACKEND_CHECK); - if (!(flag & flags_mask)) { - flag = (1U << (flag - 1)) | flags_mask; - } - - if (flag & (1U << (cmd->flag - 1))) { - flag &= ~(1U << (cmd->flag - 1)); - - if (flag == 0) { - /* It is the last flag, so delete hash completely */ - rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE, - RSPAMD_FUZZY_BACKEND_DELETE, - cmd->digest); - } - else { - /* We need to delete specific flag */ - rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE, - RSPAMD_FUZZY_BACKEND_UPDATE_FLAG, - (gint64) cmd->value, - (gint64) flag, - 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 { - /* The hash has a wrong flag, ignoring */ + rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE, + RSPAMD_FUZZY_BACKEND_DELETE, + 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 { |