]> source.dussan.org Git - rspamd.git/commitdiff
Some fixes to fuzzy matching
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 22 Dec 2014 17:57:04 +0000 (17:57 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 22 Dec 2014 17:57:04 +0000 (17:57 +0000)
src/libserver/fuzzy_backend.c

index 3a4c198a76d3b6690d7caa11a8e392ad2b7dd224..03d40161b6ba186a6f36d0f261b5a3cecbf6d05e 100644 (file)
@@ -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);
                                }
                        }
                }