pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-pcu/+/32377 )
Change subject: tbf: Move m_ctrs alloc to constructor
......................................................................
tbf: Move m_ctrs alloc to constructor
Move rate_ctr allocation to the constructor since it its expected not to
fail. This simplifies further tbf::setup() function.
Change-Id: If64443c38624d159e68eec3a07d8e8caf369467b
---
M src/tbf.cpp
M src/tbf_ul.cpp
2 files changed, 16 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/77/32377/1
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 797a95d..2f832a5 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -129,6 +129,9 @@
m_created_ts = time(NULL);
/* set timestamp */
osmo_clock_gettime(CLOCK_MONOTONIC, &meas.rssi_tv);
+
+ m_ctrs = rate_ctr_group_alloc(this, &tbf_ctrg_desc, next_tbf_ctr_group_id++);
+ OSMO_ASSERT(m_ctrs);
}
@@ -592,12 +595,6 @@
"Allocated: trx = %d, ul_slots = %02x, dl_slots = %02x\n",
this->trx->trx_no, ul_slots(), dl_slots());
- m_ctrs = rate_ctr_group_alloc(this, &tbf_ctrg_desc, next_tbf_ctr_group_id++);
- if (!m_ctrs) {
- LOGPTBF(this, LOGL_ERROR, "Couldn't allocate TBF counters\n");
- return -1;
- }
-
tbf_update_state_fsm_name(this);
ms_attach_tbf(m_ms, this);
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index a0e0398..608714d 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -168,14 +168,13 @@
/* The only one TS is the common, control TS */
ms_set_first_common_ts(ms, pdch);
tbf_assign_control_ts(ul_tbf);
- 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,
ul_tbf->m_ctrs->idx);
ul_tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(ul_tbf,
&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) {
+ if (!ul_tbf->m_ul_egprs_ctrs || !ul_tbf->m_ul_gprs_ctrs) {
LOGPTBF(ul_tbf, LOGL_ERROR, "Could not allocate TBF UL rate counters\n");
talloc_free(ul_tbf);
return NULL;
--
To view, visit
https://gerrit.osmocom.org/c/osmo-pcu/+/32377
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: If64443c38624d159e68eec3a07d8e8caf369467b
Gerrit-Change-Number: 32377
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange