]> source.dussan.org Git - rspamd.git/commitdiff
Don't fail stats when pre-results are set
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 12 Feb 2016 16:27:25 +0000 (16:27 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 12 Feb 2016 16:27:25 +0000 (16:27 +0000)
src/libstat/learn_cache/redis_cache.c
src/libstat/learn_cache/sqlite3_cache.c

index ec2203463cdb87af9a156cfcc8b2a555ac5034c2..47bfd89a6a171dc5a3d9065d8b51c01ca4abf463 100644 (file)
@@ -270,6 +270,10 @@ rspamd_stat_cache_redis_runtime (struct rspamd_task *task,
                return NULL;
        }
 
+       if (task->tokens == NULL || task->tokens->len == 0) {
+               return NULL;
+       }
+
        if (learn) {
                up = rspamd_upstream_get (ctx->write_servers,
                                RSPAMD_UPSTREAM_MASTER_SLAVE,
@@ -322,7 +326,10 @@ rspamd_stat_cache_redis_check (struct rspamd_task *task,
        gchar *h;
 
        h = rspamd_mempool_get_variable (task->task_pool, "words_hash");
-       g_assert (h != NULL);
+
+       if (h == NULL) {
+               return RSPAMD_LEARN_INGORE;
+       }
 
        double_to_tv (rt->ctx->timeout, &tv);
 
index 288cad0ee39a35e19cc36836120b71adbeaad84c..41731fa10ba41047b4bd0b15864d75b816e3eb7e 100644 (file)
@@ -183,6 +183,10 @@ rspamd_stat_cache_sqlite3_check (struct rspamd_task *task,
        gint rc;
        gint64 flag;
 
+       if (task->tokens == NULL || task->tokens->len == 0) {
+               return RSPAMD_LEARN_INGORE;
+       }
+
        if (ctx != NULL && ctx->db != NULL) {
                out = rspamd_mempool_alloc (task->task_pool, rspamd_cryptobox_HASHBYTES);
 
@@ -223,9 +227,6 @@ rspamd_stat_cache_sqlite3_check (struct rspamd_task *task,
                                return RSPAMD_LEARN_UNLEARN;
                        }
                }
-               else {
-
-               }
        }
 
        return RSPAMD_LEARN_OK;
@@ -242,7 +243,10 @@ rspamd_stat_cache_sqlite3_learn (struct rspamd_task *task,
        gint64 flag;
 
        h = rspamd_mempool_get_variable (task->task_pool, "words_hash");
-       g_assert (h != NULL);
+
+       if (h == NULL) {
+               return RSPAMD_LEARN_INGORE;
+       }
 
        flag = !!is_spam ? 1 : 0;