diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-06-20 08:47:45 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-06-20 08:47:45 +0100 |
commit | 22794d547d1147d31bb226912ea37bfc8bf8d5f1 (patch) | |
tree | 154052be24330b9fab583937818003f6c7a60060 | |
parent | 89bc0e860425086da5123eed134ab60836d6720c (diff) | |
download | rspamd-22794d547d1147d31bb226912ea37bfc8bf8d5f1.tar.gz rspamd-22794d547d1147d31bb226912ea37bfc8bf8d5f1.zip |
[Minor] Return number of hits for a symbol when querying
-rw-r--r-- | src/controller.c | 2 | ||||
-rw-r--r-- | src/libserver/symbols_cache.c | 10 | ||||
-rw-r--r-- | src/libserver/symbols_cache.h | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/controller.c b/src/controller.c index b72f0ad4f..3d88aa090 100644 --- a/src/controller.c +++ b/src/controller.c @@ -816,7 +816,7 @@ rspamd_controller_handle_symbols (struct rspamd_http_connection_entry *conn_ent, } if (rspamd_symbols_cache_stat_symbol (session->ctx->cfg->cache, - sym->name, &freq, &freq_dev, &tm)) { + sym->name, &freq, &freq_dev, &tm, NULL)) { ucl_object_insert_key (sym_obj, ucl_object_fromdouble (freq), "frequency", 0, false); diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c index 8df440d1c..0728d0ee6 100644 --- a/src/libserver/symbols_cache.c +++ b/src/libserver/symbols_cache.c @@ -2136,10 +2136,8 @@ rspamd_symbols_cache_find_symbol (struct symbols_cache *cache, const gchar *name gboolean rspamd_symbols_cache_stat_symbol (struct symbols_cache *cache, - const gchar *name, - gdouble *frequency, - gdouble *freq_stddev, - gdouble *tm) + const gchar *name, gdouble *frequency, gdouble *freq_stddev, + gdouble *tm, guint *nhits) { struct cache_item *item; @@ -2156,6 +2154,10 @@ rspamd_symbols_cache_stat_symbol (struct symbols_cache *cache, *freq_stddev = sqrt (item->st->stddev_frequency); *tm = item->st->time_counter.mean; + if (nhits) { + *nhits = item->st->hits; + } + return TRUE; } diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h index b003eebab..b71c6e9b9 100644 --- a/src/libserver/symbols_cache.h +++ b/src/libserver/symbols_cache.h @@ -141,10 +141,8 @@ gint rspamd_symbols_cache_find_symbol (struct symbols_cache *cache, * @return */ gboolean rspamd_symbols_cache_stat_symbol (struct symbols_cache *cache, - const gchar *name, - gdouble *frequency, - gdouble *freq_stddev, - gdouble *tm); + const gchar *name, gdouble *frequency, gdouble *freq_stddev, + gdouble *tm, guint *nhits); /** * Find symbol in cache by its id * @param cache |