From 0da9afe73cb379d5bb6235f2a2ef5a9d7595f386 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 28 Nov 2016 13:51:13 +0000 Subject: [PATCH] [Fix] Fix total learns counter for redis stats --- src/libstat/stat_process.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 04ebe72af..2d3a83e10 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -1132,10 +1132,18 @@ rspamd_stat_statistics (struct rspamd_task *task, st = g_ptr_array_index (st_ctx->statfiles, id); backend_runtime = st->backend->runtime (task, st->stcf, FALSE, st->bkcf); - learns += st->backend->total_learns (task, backend_runtime, - st->bkcf); elt = st->backend->get_stat (backend_runtime, st->bkcf); + if (elt && ucl_object_type (elt) == UCL_OBJECT) { + const ucl_object_t *rev = ucl_object_lookup (elt, "revision"); + + learns += ucl_object_toint (rev); + } + else { + learns += st->backend->total_learns (task, backend_runtime, + st->bkcf); + } + if (elt != NULL) { ucl_array_append (res, elt); } -- 2.39.5