aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-06-29 16:44:23 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2020-06-29 16:51:08 +0200
commitfb96767ac5c26cd40f4b50ae2c87724bd3e1af2c (patch)
treebcf900297783f9911e90d2d0515412a3e73c2d1c
parent394053e5993cb25dc267168002410ef272dc8624 (diff)
trx_rate_ctr: Fix immediate rescheduling on per-sec thresholds
For instance, use in VTY: "ctr-error-threshold tx_underruns 5 per-second" If the condition becomes true (eg 5 underruns happened in one sec), the statement inside OSMO_MAX would become -1, but it was being handled as an unsigned when doing the OSMO_MAX internal comparison. As a result, OSMO_MAX((unsigned)-1, 1) was returning -1 (unsigned) stored in threshold_timer_sched_secs which then became and int -1, which was handled by osmo_timer_schedule as a 0, hence having an immediate trigerring all the time. While at it, make threshold_timer_sched_secs unsigned since it doesn't make sense to have it as signed anyway. Change-Id: I6ea3d64dff189a5bc924e72d846e02d50536a8ea
-rw-r--r--CommonLibs/trx_rate_ctr.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/CommonLibs/trx_rate_ctr.cpp b/CommonLibs/trx_rate_ctr.cpp
index d10b315..381b387 100644
--- a/CommonLibs/trx_rate_ctr.cpp
+++ b/CommonLibs/trx_rate_ctr.cpp
@@ -81,7 +81,7 @@ static Mutex rate_ctr_mutex;
struct osmo_timer_list threshold_timer;
static LLIST_HEAD(threshold_list);
-static int threshold_timer_sched_secs;
+static unsigned int threshold_timer_sched_secs;
static bool threshold_initied;
const struct value_string rate_ctr_intv[] = {
@@ -260,7 +260,7 @@ static void threshold_timer_update_intv() {
}
- threshold_timer_sched_secs = OSMO_MAX(min_secs / 2 - 1, 1);
+ threshold_timer_sched_secs = OSMO_MAX((int)(min_secs / 2 - 1), 1);
LOGC(DMAIN, INFO) << "New ctr-error-threshold check interval: "
<< threshold_timer_sched_secs << " seconds";
osmo_timer_schedule(&threshold_timer, threshold_timer_sched_secs, 0);