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
This commit is contained in:
parent
394053e599
commit
fb96767ac5
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue