diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-12-22 17:57:04 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-12-22 17:57:04 +0000 |
commit | 470f3b94beef886189bf749955444553afa3886e (patch) | |
tree | c50f82075246b67613ffbde95109810208f56bd0 /src/libserver/fuzzy_backend.c | |
parent | f912ce34c0fa3a4472f05a4428a3062bf537bd3d (diff) | |
download | rspamd-470f3b94beef886189bf749955444553afa3886e.tar.gz rspamd-470f3b94beef886189bf749955444553afa3886e.zip |
Some fixes to fuzzy matching
Diffstat (limited to 'src/libserver/fuzzy_backend.c')
-rw-r--r-- | src/libserver/fuzzy_backend.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libserver/fuzzy_backend.c b/src/libserver/fuzzy_backend.c index 3a4c198a7..03d40161b 100644 --- a/src/libserver/fuzzy_backend.c +++ b/src/libserver/fuzzy_backend.c @@ -610,7 +610,7 @@ rspamd_fuzzy_backend_check (struct rspamd_fuzzy_backend *backend, cur_cnt ++; } else { - if (cur_cnt > max_cnt) { + if (cur_cnt >= max_cnt) { max_cnt = cur_cnt; sel_id = cur_id; } @@ -619,6 +619,10 @@ rspamd_fuzzy_backend_check (struct rspamd_fuzzy_backend *backend, } } + if (cur_cnt > max_cnt) { + max_cnt = cur_cnt; + } + if (sel_id != -1) { /* We have some id selected here */ rep.prob = (gdouble)max_cnt / (gdouble)RSPAMD_SHINGLE_SIZE; @@ -627,9 +631,9 @@ rspamd_fuzzy_backend_check (struct rspamd_fuzzy_backend *backend, RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID, sel_id); if (rc == SQLITE_OK) { digest = sqlite3_column_text ( - prepared_stmts[RSPAMD_FUZZY_BACKEND_CHECK].stmt, 0); + prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt, 0); timestamp = sqlite3_column_int64 ( - prepared_stmts[RSPAMD_FUZZY_BACKEND_CHECK].stmt, 2); + prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt, 2); if (time (NULL) - timestamp > expire) { /* Expire element */ msg_debug ("requested hash has been expired"); @@ -640,9 +644,9 @@ rspamd_fuzzy_backend_check (struct rspamd_fuzzy_backend *backend, } else { rep.value = sqlite3_column_int64 ( - prepared_stmts[RSPAMD_FUZZY_BACKEND_CHECK].stmt, 1); + prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt, 1); rep.flag = sqlite3_column_int ( - prepared_stmts[RSPAMD_FUZZY_BACKEND_CHECK].stmt, 3); + prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt, 3); } } } |