Change in osmo-pcu[master]: Explicitly clean up BTS singleton

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

Max gerrit-no-reply at lists.osmocom.org
Tue Mar 19 13:36:27 UTC 2019


Max has uploaded this change for review. ( https://gerrit.osmocom.org/13318


Change subject: Explicitly clean up BTS singleton
......................................................................

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
---
M src/bts.cpp
M src/bts.h
M src/pcu_main.cpp
3 files changed, 22 insertions(+), 3 deletions(-)



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

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 @@
 	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 @@
 	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 @@
 
 	BTS();
 	~BTS();
+	void cleanup();
 
 	static BTS* main_bts();
 
@@ -591,6 +592,7 @@
 #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 @@
 
 	pcu_l1if_close();
 
+	bts_cleanup();
 	talloc_report_full(tall_pcu_ctx, stderr);
 	talloc_free(tall_pcu_ctx);
 

-- 
To view, visit https://gerrit.osmocom.org/13318
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: I796d56a7de3f3a1f9d59708995c8e3e9b05a2747
Gerrit-Change-Number: 13318
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190319/6987d8a3/attachment.htm>


More information about the gerrit-log mailing list