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
This commit is contained in:
Pau Espin 2021-07-26 18:24:14 +02:00
parent 9dacf0b35b
commit 131deb059f
4 changed files with 15 additions and 11 deletions

View File

@ -164,6 +164,7 @@ gprs_rlcmac_tbf::~gprs_rlcmac_tbf()
{ {
osmo_fsm_inst_free(state_fsm.fi); osmo_fsm_inst_free(state_fsm.fi);
state_fsm.fi = NULL; state_fsm.fi = NULL;
rate_ctr_group_free(m_ctrs);
} }
uint32_t gprs_rlcmac_tbf::tlli() const uint32_t gprs_rlcmac_tbf::tlli() const
@ -269,19 +270,11 @@ void tbf_free(struct gprs_rlcmac_tbf *tbf)
{ {
/* update counters */ /* update counters */
if (tbf->direction == GPRS_RLCMAC_UL_TBF) { 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); bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_UL_FREED);
if (tbf->state_is(TBF_ST_FLOW)) if (tbf->state_is(TBF_ST_FLOW))
bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_UL_ABORTED); 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 { } else {
gprs_rlcmac_dl_tbf *dl_tbf = as_dl_tbf(tbf); 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); bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_DL_FREED);
if (tbf->state_is(TBF_ST_FLOW)) if (tbf->state_is(TBF_ST_FLOW))
bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_DL_ABORTED); bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_DL_ABORTED);
@ -297,8 +290,6 @@ void tbf_free(struct gprs_rlcmac_tbf *tbf)
if (tbf->ms()) if (tbf->ms())
tbf->set_ms(NULL); tbf->set_ms(NULL);
rate_ctr_group_free(tbf->m_ctrs);
LOGP(DTBF, LOGL_DEBUG, "********** %s-TBF ends here **********\n", LOGP(DTBF, LOGL_DEBUG, "********** %s-TBF ends here **********\n",
(tbf->direction != GPRS_RLCMAC_UL_TBF) ? "DL" : "UL"); (tbf->direction != GPRS_RLCMAC_UL_TBF) ? "DL" : "UL");
talloc_free(tbf); talloc_free(tbf);

View File

@ -180,7 +180,12 @@ struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts, GprsMs
gprs_rlcmac_dl_tbf::~gprs_rlcmac_dl_tbf() gprs_rlcmac_dl_tbf::~gprs_rlcmac_dl_tbf()
{ {
osmo_timer_del(&m_llc_timer); 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) : gprs_rlcmac_dl_tbf::gprs_rlcmac_dl_tbf(struct gprs_rlcmac_bts *bts_, GprsMs *ms) :

View File

@ -91,6 +91,13 @@ static const struct rate_ctr_group_desc tbf_ul_egprs_ctrg_desc = {
tbf_ul_egprs_ctr_description, 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) static int ul_tbf_dtor(struct gprs_rlcmac_ul_tbf *tbf)
{ {
tbf->~gprs_rlcmac_ul_tbf(); tbf->~gprs_rlcmac_ul_tbf();

View File

@ -54,6 +54,7 @@ enum tbf_egprs_ul_counters {
struct gprs_rlcmac_ul_tbf : public gprs_rlcmac_tbf { struct gprs_rlcmac_ul_tbf : public gprs_rlcmac_tbf {
gprs_rlcmac_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms); gprs_rlcmac_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms);
~gprs_rlcmac_ul_tbf();
gprs_rlc_window *window(); gprs_rlc_window *window();
struct msgb *create_ul_ack(uint32_t fn, uint8_t ts); struct msgb *create_ul_ack(uint32_t fn, uint8_t ts);
bool ctrl_ack_to_toggle(); bool ctrl_ack_to_toggle();