summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-05-08 16:58:34 +0200
committerHarald Welte <laforge@gnumonks.org>2019-05-10 07:09:51 +0000
commit9685a48c7bc83b1f5ee9b51e29419164b387ade2 (patch)
tree9da4e1d020174bc500bb28837ad629ef77970e6c /src
parent37db7d3ea6d9f62940b26dc5e9f9457a8c35eced (diff)
Print error message if application fails to call rate_ctr_init()
Change-Id: Ie8093b66b7e27cf863d2558fe21b2c6e0f3fcdfd Closes: OS#3580
Diffstat (limited to 'src')
-rw-r--r--src/rate_ctr.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/rate_ctr.c b/src/rate_ctr.c
index 026670bd..99ec5234 100644
--- a/src/rate_ctr.c
+++ b/src/rate_ctr.c
@@ -69,7 +69,7 @@
#include <osmocom/core/logging.h>
static LLIST_HEAD(rate_ctr_groups);
-
+static struct osmo_timer_list rate_ctr_timer;
static void *tall_rate_ctr_ctx;
@@ -217,6 +217,10 @@ struct rate_ctr_group *rate_ctr_group_alloc(void *ctx,
unsigned int size;
struct rate_ctr_group *group;
+ if (!osmo_timer_pending(&rate_ctr_timer))
+ LOGP(DLGLOBAL, LOGL_ERROR, "your program appears to use libosmocore rate_ctr "
+ "without calling rate_ctr_init() at start-up. Rate counters won't work!\n");
+
if (rate_ctr_get_group_by_name_idx(desc->group_name_prefix, idx)) {
unsigned int new_idx = rate_ctr_get_unused_name_idx(desc->group_name_prefix);
LOGP(DLGLOBAL, LOGL_ERROR, "counter group '%s' already exists for index %u,"
@@ -294,7 +298,6 @@ static void interval_expired(struct rate_ctr *ctr, enum rate_ctr_intv intv)
ctr->intv[intv+1].rate += ctr->intv[intv].rate;
}
-static struct osmo_timer_list rate_ctr_timer;
static uint64_t timer_ticks;
/* The one-second interval has expired */