From: Vsevolod Stakhov Date: Sat, 16 Sep 2017 14:33:39 +0000 (+0100) Subject: [Fix] Skip nostat tokens when get number of tokens X-Git-Tag: 1.7.0~639 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d999f2bf3873910f5160429b42885073324f6479;p=thirdparty%2Frspamd.git [Fix] Skip nostat tokens when get number of tokens --- diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c index c76c17e4e2..d07d42d10f 100644 --- a/src/libserver/symbols_cache.c +++ b/src/libserver/symbols_cache.c @@ -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 diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h index f6bbd599b9..d959f905eb 100644 --- a/src/libserver/symbols_cache.h +++ b/src/libserver/symbols_cache.h @@ -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 diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 6dfd45e126..d35cd84a6e 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -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"); diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 614c059dd1..e3dcfc6027 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -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;