Change in osmo-pcu[master]: Move rate_ctr free to tbf subclass destructor

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 Aug 23 16:28:09 UTC 2021


pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/25053 )

Change subject: Move rate_ctr free to tbf subclass destructor
......................................................................

Move rate_ctr free to tbf subclass destructor

This way we clean up tbf_free entry point, and leave memory freeing for
later on at the end when talloc_free is called.

Change-Id: I1c45e3296e565725bcbbca391d9518772fffa89d
---
M src/tbf.cpp
M src/tbf_dl.cpp
M src/tbf_ul.cpp
M src/tbf_ul.h
4 files changed, 15 insertions(+), 11 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, approved
  osmith: Looks good to me, but someone else must approve



diff --git a/src/tbf.cpp b/src/tbf.cpp
index ca0dc41..16a53cc 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -164,6 +164,7 @@
 {
 	osmo_fsm_inst_free(state_fsm.fi);
 	state_fsm.fi = NULL;
+	rate_ctr_group_free(m_ctrs);
 }
 
 uint32_t gprs_rlcmac_tbf::tlli() const
@@ -269,19 +270,11 @@
 {
 	/* update counters */
 	if (tbf->direction == GPRS_RLCMAC_UL_TBF) {
-		gprs_rlcmac_ul_tbf *ul_tbf = as_ul_tbf(tbf);
 		bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_UL_FREED);
 		if (tbf->state_is(TBF_ST_FLOW))
 			bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_UL_ABORTED);
-		rate_ctr_group_free(ul_tbf->m_ul_egprs_ctrs);
-		rate_ctr_group_free(ul_tbf->m_ul_gprs_ctrs);
 	} else {
 		gprs_rlcmac_dl_tbf *dl_tbf = as_dl_tbf(tbf);
-		if (tbf->is_egprs_enabled()) {
-			rate_ctr_group_free(dl_tbf->m_dl_egprs_ctrs);
-		} else {
-			rate_ctr_group_free(dl_tbf->m_dl_gprs_ctrs);
-		}
 		bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_DL_FREED);
 		if (tbf->state_is(TBF_ST_FLOW))
 			bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_DL_ABORTED);
@@ -297,8 +290,6 @@
 	if (tbf->ms())
 		tbf->set_ms(NULL);
 
-	rate_ctr_group_free(tbf->m_ctrs);
-
 	LOGP(DTBF, LOGL_DEBUG, "********** %s-TBF ends here **********\n",
 	     (tbf->direction != GPRS_RLCMAC_UL_TBF) ? "DL" : "UL");
 	talloc_free(tbf);
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index e76ea8c..0330a78 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -180,7 +180,12 @@
 gprs_rlcmac_dl_tbf::~gprs_rlcmac_dl_tbf()
 {
 	osmo_timer_del(&m_llc_timer);
-	/* ~gprs_rlcmac_dl_tbf() is called automatically upon return */
+	if (is_egprs_enabled()) {
+		rate_ctr_group_free(m_dl_egprs_ctrs);
+	} else {
+		rate_ctr_group_free(m_dl_gprs_ctrs);
+	}
+	/* ~gprs_rlcmac_tbf() is called automatically upon return */
 }
 
 gprs_rlcmac_dl_tbf::gprs_rlcmac_dl_tbf(struct gprs_rlcmac_bts *bts_, GprsMs *ms) :
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index d4575a3..6e50734 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -91,6 +91,13 @@
 	tbf_ul_egprs_ctr_description,
 };
 
+gprs_rlcmac_ul_tbf::~gprs_rlcmac_ul_tbf()
+{
+	rate_ctr_group_free(m_ul_egprs_ctrs);
+	rate_ctr_group_free(m_ul_gprs_ctrs);
+	/* ~gprs_rlcmac_tbf() is called automatically upon return */
+}
+
 static int ul_tbf_dtor(struct gprs_rlcmac_ul_tbf *tbf)
 {
 	tbf->~gprs_rlcmac_ul_tbf();
diff --git a/src/tbf_ul.h b/src/tbf_ul.h
index 9396633..2bc908d 100644
--- a/src/tbf_ul.h
+++ b/src/tbf_ul.h
@@ -54,6 +54,7 @@
 
 struct gprs_rlcmac_ul_tbf : public gprs_rlcmac_tbf {
 	gprs_rlcmac_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms);
+	~gprs_rlcmac_ul_tbf();
 	gprs_rlc_window *window();
 	struct msgb *create_ul_ack(uint32_t fn, uint8_t ts);
 	bool ctrl_ack_to_toggle();

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I1c45e3296e565725bcbbca391d9518772fffa89d
Gerrit-Change-Number: 25053
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210823/70ae5eaa/attachment.htm>


More information about the gerrit-log mailing list