<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-trx/+/19049">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">trx_rate_ctr: Fix immediate rescheduling on per-sec thresholds<br><br>For instance, use in VTY:<br>"ctr-error-threshold tx_underruns 5 per-second"<br><br>If the condition becomes true (eg 5 underruns happened in one sec), the<br>statement inside OSMO_MAX would become -1, but it was being handled as<br>an unsigned when doing the OSMO_MAX internal comparison. As a result,<br>OSMO_MAX((unsigned)-1, 1) was returning -1 (unsigned) stored in<br>threshold_timer_sched_secs which then became and int -1, which was<br>handled by osmo_timer_schedule as a 0, hence having an immediate<br>trigerring all the time.<br><br>While at it, make threshold_timer_sched_secs unsigned since it doesn't<br>make sense to have it as signed anyway.<br><br>Change-Id: I6ea3d64dff189a5bc924e72d846e02d50536a8ea<br>---<br>M CommonLibs/trx_rate_ctr.cpp<br>1 file changed, 2 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/49/19049/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/CommonLibs/trx_rate_ctr.cpp b/CommonLibs/trx_rate_ctr.cpp</span><br><span>index d10b315..381b387 100644</span><br><span>--- a/CommonLibs/trx_rate_ctr.cpp</span><br><span>+++ b/CommonLibs/trx_rate_ctr.cpp</span><br><span>@@ -81,7 +81,7 @@</span><br><span> </span><br><span> struct osmo_timer_list threshold_timer;</span><br><span> static LLIST_HEAD(threshold_list);</span><br><span style="color: hsl(0, 100%, 40%);">-static int threshold_timer_sched_secs;</span><br><span style="color: hsl(120, 100%, 40%);">+static unsigned int threshold_timer_sched_secs;</span><br><span> static bool threshold_initied;</span><br><span> </span><br><span> const struct value_string rate_ctr_intv[] = {</span><br><span>@@ -260,7 +260,7 @@</span><br><span>        }</span><br><span> </span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-       threshold_timer_sched_secs = OSMO_MAX(min_secs / 2 - 1, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+   threshold_timer_sched_secs = OSMO_MAX((int)(min_secs / 2 - 1), 1);</span><br><span>   LOGC(DMAIN, INFO) << "New ctr-error-threshold check interval: "</span><br><span>                        << threshold_timer_sched_secs << " seconds";</span><br><span>         osmo_timer_schedule(&threshold_timer, threshold_timer_sched_secs, 0);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-trx/+/19049">change 19049</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-trx/+/19049"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-trx </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I6ea3d64dff189a5bc924e72d846e02d50536a8ea </div>
<div style="display:none"> Gerrit-Change-Number: 19049 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>