From: Vsevolod Stakhov Date: Mon, 22 Dec 2014 17:57:04 +0000 (+0000) Subject: Some fixes to fuzzy matching X-Git-Tag: 0.8.0~31 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=470f3b94beef886189bf749955444553afa3886e;p=rspamd.git Some fixes to fuzzy matching --- 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); } } }