From 248236db6d5feb21915ea10537bfec2b2d9899d4 Mon Sep 17 00:00:00 2001 From: Vojtech Vilimek Date: Fri, 15 Jul 2022 13:59:14 +0200 Subject: [PATCH] Fix bug in stats_rt_notify() --- proto/stats/stats.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/proto/stats/stats.c b/proto/stats/stats.c index a648f49d..ab0b664a 100644 --- a/proto/stats/stats.c +++ b/proto/stats/stats.c @@ -36,24 +36,17 @@ stats_rt_notify(struct proto *P, struct channel *src_ch, const net_addr *n, rte struct stats_config *cf = (void *) P->cf; log(L_INFO "stats_rf_notify()"); - if (new && old) + if (old) { - new->generation = old->generation + 1; p->counters[old->generation]--; + log(L_INFO "counter %u decreased", old->generation); + } + + if (new) + { p->counters[new->generation]++; log(L_INFO "counter %u increased", new->generation); } - else if (new && !old) - { - new->generation = 0; - p->counters[0]++; - log(L_INFO "counter 0 increased"); - } - else if (!new && old) - { - (p->counters[old->generation])--; - log(L_INFO "counter %u decreased", old->generation); - } } static int