]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Skip nostat tokens when get number of tokens
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 16 Sep 2017 14:33:39 +0000 (15:33 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 16 Sep 2017 14:33:39 +0000 (15:33 +0100)
src/libserver/symbols_cache.c
src/libserver/symbols_cache.h
src/lua/lua_config.c
src/lua/lua_task.c

index c76c17e4e2b806ca64ec8a6afc0a73bc46a711e0..d07d42d10f94d7fc58fe3390acb1de77d39dc06c 100644 (file)
@@ -74,6 +74,7 @@ struct symbols_cache {
        guint64 cksum;
        gdouble total_weight;
        guint used_items;
+       guint stats_symbols_count;
        guint64 total_hits;
        struct rspamd_config *cfg;
        rspamd_mempool_mutex_t *mtx;
@@ -778,6 +779,8 @@ rspamd_symbols_cache_add_symbol (struct symbols_cache *cache,
                        cache->cksum = t1ha (&item->id, sizeof (item->id),
                                        cache->cksum);
                }
+
+               cache->stats_symbols_count ++;
        }
 
        if (name != NULL) {
@@ -2290,11 +2293,11 @@ rspamd_symbols_cache_symbol_by_id (struct symbols_cache *cache,
 }
 
 guint
-rspamd_symbols_cache_symbols_count (struct symbols_cache *cache)
+rspamd_symbols_cache_stats_symbols_count (struct symbols_cache *cache)
 {
        g_assert (cache != NULL);
 
-       return cache->items_by_id->len;
+       return cache->stats_symbols_count;
 }
 
 static void
index f6bbd599b9616d3b9d0549b56405d86f4d3f801b..d959f905eb58b9c185b4c4089560b1ffd3f9362f 100644 (file)
@@ -159,7 +159,7 @@ const gchar * rspamd_symbols_cache_symbol_by_id (struct symbols_cache *cache,
  * @param cache
  * @return number of symbols in the cache
  */
-guint rspamd_symbols_cache_symbols_count (struct symbols_cache *cache);
+guint rspamd_symbols_cache_stats_symbols_count (struct symbols_cache *cache);
 
 /**
  * Call function for cached symbol using saved callback
index 6dfd45e12697c0f3813b6c5397be6c38e6e24696..d35cd84a6e9a3874cd8bc011f7fd9297d4db403b 100644 (file)
@@ -2548,7 +2548,7 @@ lua_config_get_symbols_count (lua_State *L)
        guint res = 0;
 
        if (cfg != NULL) {
-               res = rspamd_symbols_cache_symbols_count (cfg->cache);
+               res = rspamd_symbols_cache_stats_symbols_count (cfg->cache);
        }
        else {
                return luaL_error (L, "invalid arguments");
index 614c059dd16cdd97ad5873672c3c44767a588dc1..e3dcfc60274b1d782c961c9462b96e535c5bad7f 100644 (file)
@@ -3183,7 +3183,8 @@ lua_task_get_symbols_tokens (lua_State *L)
                cbd.normalize = TRUE;
        }
 
-       lua_createtable (L, rspamd_symbols_cache_symbols_count (task->cfg->cache), 0);
+       lua_createtable (L,
+                       rspamd_symbols_cache_stats_symbols_count (task->cfg->cache), 0);
        rspamd_symbols_cache_foreach (task->cfg->cache, tokens_foreach_cb, &cbd);
 
        return 1;