Change in osmo-pcu[master]: tbf: Use incrementing id for rate_ctr_group_alloc

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/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Tue Jul 10 13:47:55 UTC 2018


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/9943


Change subject: tbf: Use incrementing id for rate_ctr_group_alloc
......................................................................

tbf: Use incrementing id for rate_ctr_group_alloc

Wrap-around of var handling next id will luckly happen
long after initially assigned TBFs are already released.

Change-Id: I90ef64133986c556c1a529f5b966e847e6cabbad
---
M src/tbf.cpp
1 file changed, 18 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/43/9943/1

diff --git a/src/tbf.cpp b/src/tbf.cpp
index 71057db..6792d08 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -51,6 +51,8 @@
 
 extern void *tall_pcu_ctx;
 
+static unsigned int next_tbf_ctr_group_id = 0; /* Incrementing group id */
+
 static void tbf_timer_cb(void *_tbf);
 
 const struct value_string gprs_rlcmac_tbf_poll_state_names[] = {
@@ -922,7 +924,7 @@
 		"Allocated: trx = %d, ul_slots = %02x, dl_slots = %02x\n",
 		tbf->trx->trx_no, tbf->ul_slots(), tbf->dl_slots());
 
-	tbf->m_ctrs = rate_ctr_group_alloc(tbf, &tbf_ctrg_desc, 0);
+	tbf->m_ctrs = rate_ctr_group_alloc(tbf, &tbf_ctrg_desc, next_tbf_ctr_group_id++);
 	if (!tbf->m_ctrs) {
 		LOGPTBF(tbf, LOGL_ERROR, "Couldn't allocate TBF counters\n");
 		return -1;
@@ -1005,8 +1007,10 @@
 		return NULL;
 	}
 
-	tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_ul_egprs_ctrg_desc, 0);
-	tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_ul_gprs_ctrg_desc, 0);
+	tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(tbf,
+					&tbf_ul_egprs_ctrg_desc, tbf->m_ctrs->idx);
+	tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(tbf,
+					&tbf_ul_gprs_ctrg_desc, tbf->m_ctrs->idx);
 	if (!tbf->m_ul_egprs_ctrs || !tbf->m_ul_gprs_ctrs) {
 		LOGPTBF(tbf, LOGL_ERROR, "Couldn't allocate TBF UL counters\n");
 		talloc_free(tbf);
@@ -1094,14 +1098,18 @@
 
 	if (tbf->is_egprs_enabled()) {
 		tbf->set_window_size();
-		tbf->m_dl_egprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_dl_egprs_ctrg_desc, 0);
+		tbf->m_dl_egprs_ctrs = rate_ctr_group_alloc(tbf,
+							&tbf_dl_egprs_ctrg_desc,
+							tbf->m_ctrs->idx);
 		if (!tbf->m_dl_egprs_ctrs) {
 			LOGPTBF(tbf, LOGL_ERROR, "Couldn't allocate EGPRS DL counters\n");
 			talloc_free(tbf);
 			return NULL;
 		}
 	} else {
-		tbf->m_dl_gprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_dl_gprs_ctrg_desc, 0);
+		tbf->m_dl_gprs_ctrs = rate_ctr_group_alloc(tbf,
+							&tbf_dl_gprs_ctrg_desc,
+							tbf->m_ctrs->idx);
 		if (!tbf->m_dl_gprs_ctrs) {
 			LOGPTBF(tbf, LOGL_ERROR, "Couldn't allocate GPRS DL counters\n");
 			talloc_free(tbf);
@@ -1569,11 +1577,13 @@
 	TBF_SET_ASS_STATE_UL(ul_tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ);
 	ul_tbf->control_ts = ts;
 	ul_tbf->trx = trx;
-	ul_tbf->m_ctrs = rate_ctr_group_alloc(ul_tbf, &tbf_ctrg_desc, 0);
+	ul_tbf->m_ctrs = rate_ctr_group_alloc(ul_tbf, &tbf_ctrg_desc, next_tbf_ctr_group_id++);
 	ul_tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(ul_tbf,
-					&tbf_ul_egprs_ctrg_desc, 0);
+						       &tbf_ul_egprs_ctrg_desc,
+						       ul_tbf->m_ctrs->idx);
 	ul_tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(ul_tbf,
-					&tbf_ul_gprs_ctrg_desc, 0);
+						      &tbf_ul_gprs_ctrg_desc,
+						      ul_tbf->m_ctrs->idx);
 	if (!ul_tbf->m_ctrs || !ul_tbf->m_ul_egprs_ctrs || !ul_tbf->m_ul_gprs_ctrs) {
 		LOGPTBF(ul_tbf, LOGL_ERROR, "Cound not allocate TBF UL rate counters\n");
 		talloc_free(ul_tbf);

-- 
To view, visit https://gerrit.osmocom.org/9943
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I90ef64133986c556c1a529f5b966e847e6cabbad
Gerrit-Change-Number: 9943
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180710/f9ed15cb/attachment.htm>


More information about the gerrit-log mailing list