Change in osmo-trx[master]: trx_rate_ctr: Fix immediate rescheduling on per-sec thresholds

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Mon Jun 29 14:51:16 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-trx/+/19049 )


Change subject: trx_rate_ctr: Fix immediate rescheduling on per-sec thresholds
......................................................................

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
---
M CommonLibs/trx_rate_ctr.cpp
1 file changed, 2 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/49/19049/1

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 @@
 
 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 @@
 	}
 
 
-	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);

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/19049
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I6ea3d64dff189a5bc924e72d846e02d50536a8ea
Gerrit-Change-Number: 19049
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200629/dc4c0655/attachment.htm>


More information about the gerrit-log mailing list