aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2019-03-18 15:48:38 +0100
committerMax <msuraev@sysmocom.de>2019-03-19 15:42:10 +0000
commitd5ffeb5e63eb223852a577b8f9a3c89bf0809fb3 (patch)
treeda05a2e642d69ca9683ffee45156f58c36919d8f
parentf4d3973688a0d07cadb9e1f3529712b5e50624ea (diff)
Explicitly clean up BTS singleton
Add method to explicitly cleanup BTS singleton similar to GprsMsStorage class and use it from main(). The destructor becomes trivial wrapper around cleanup() method. This prevents annoying SIGABRT on exit of OsmoPCU caused by rate_ctr_group_free() being called after talloc_free() which removes the context in which counter group is allocated. Change-Id: I796d56a7de3f3a1f9d59708995c8e3e9b05a2747
-rw-r--r--src/bts.cpp22
-rw-r--r--src/bts.h2
-rw-r--r--src/pcu_main.cpp1
3 files changed, 22 insertions, 3 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index 1804c52..e07b840 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -197,6 +197,11 @@ struct gprs_rlcmac_bts *bts_main_data()
return BTS::main_bts()->bts_data();
}
+void bts_cleanup()
+{
+ return BTS::main_bts()->cleanup();
+}
+
struct rate_ctr_group *bts_main_data_stats()
{
return BTS::main_bts()->rate_counters();
@@ -239,16 +244,27 @@ BTS::BTS()
OSMO_ASSERT(m_statg);
}
-BTS::~BTS()
+void BTS::cleanup()
{
/* this can cause counter updates and must not be left to the
* m_ms_store's destructor */
m_ms_store.cleanup();
- rate_ctr_group_free(m_ratectrs);
- osmo_stat_item_group_free(m_statg);
+ if (m_ratectrs) {
+ rate_ctr_group_free(m_ratectrs);
+ m_ratectrs = NULL;
+ }
+
+ if (m_statg) {
+ osmo_stat_item_group_free(m_statg);
+ m_statg = NULL;
+ }
}
+BTS::~BTS()
+{
+ cleanup();
+}
void BTS::set_current_frame_number(int fn)
{
diff --git a/src/bts.h b/src/bts.h
index b83ab4b..ee5a692 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -272,6 +272,7 @@ public:
BTS();
~BTS();
+ void cleanup();
static BTS* main_bts();
@@ -591,6 +592,7 @@ CREATE_STAT_INLINE(ms_present, ms_present_get, STAT_MS_PRESENT);
#ifdef __cplusplus
extern "C" {
#endif
+ void bts_cleanup();
struct gprs_rlcmac_bts *bts_main_data();
struct rate_ctr_group *bts_main_data_stats();
struct osmo_stat_item_group *bts_main_data_stat_items();
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index a0f31d1..c39c337 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -356,6 +356,7 @@ int main(int argc, char *argv[])
pcu_l1if_close();
+ bts_cleanup();
talloc_report_full(tall_pcu_ctx, stderr);
talloc_free(tall_pcu_ctx);