[PATCH] openbsc[master]: mscsplit: talloc_ctx_init(): decouple from global tall_bsc_ctx

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Sep 22 18:56:17 UTC 2016


Review at  https://gerrit.osmocom.org/923

mscsplit: talloc_ctx_init(): decouple from global tall_bsc_ctx

Decouple the talloc context allocations from global tall_bsc_ctx pointer.

It appears that talloc_ctx_init() was intended for general use, since it is
located in libcommon. It is currently used only by osmo-nitb; but the upcoming
osmo-cscn will use it as well.

Instead of defining in osmo-nitb main file, add definition in gsm_data.h.

Change-Id: I168106599b788f586be0ff0af4699b9746c1b103
---
M openbsc/include/openbsc/gsm_data.h
M openbsc/src/libcommon/talloc_ctx.c
M openbsc/src/osmo-nitb/bsc_hack.c
3 files changed, 19 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/23/923/1

diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index fbb0356..26efeaa 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -394,6 +394,8 @@
 	char text[SMS_TEXT_SIZE];
 };
 
+extern void talloc_ctx_init(void *ctx_root);
+
 struct gsm_network *gsm_network_init(void *ctx,
 				     uint16_t country_code,
 				     uint16_t network_code,
diff --git a/openbsc/src/libcommon/talloc_ctx.c b/openbsc/src/libcommon/talloc_ctx.c
index ae6a156..f039650 100644
--- a/openbsc/src/libcommon/talloc_ctx.c
+++ b/openbsc/src/libcommon/talloc_ctx.c
@@ -17,22 +17,21 @@
 extern void *tall_upq_ctx;
 extern void *tall_ctr_ctx;
 
-void talloc_ctx_init(void)
+void talloc_ctx_init(void *ctx_root)
 {
-	tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb");
-	tall_fle_ctx = talloc_named_const(tall_bsc_ctx, 0,
-					  "bs11_file_list_entry");
-	tall_locop_ctx = talloc_named_const(tall_bsc_ctx, 0, "loc_updating_oper");
-	tall_authciphop_ctx = talloc_named_const(tall_bsc_ctx, 0, "auth_ciph_oper");
-	tall_gsms_ctx = talloc_named_const(tall_bsc_ctx, 0, "sms");
-	tall_subscr_ctx = talloc_named_const(tall_bsc_ctx, 0, "subscriber");
-	tall_sub_req_ctx = talloc_named_const(tall_bsc_ctx, 0, "subscr_request");
-	tall_call_ctx = talloc_named_const(tall_bsc_ctx, 0, "gsm_call");
-	tall_paging_ctx = talloc_named_const(tall_bsc_ctx, 0, "paging_request");
-	tall_sigh_ctx = talloc_named_const(tall_bsc_ctx, 0, "signal_handler");
-	tall_tqe_ctx = talloc_named_const(tall_bsc_ctx, 0, "subch_txq_entry");
-	tall_trans_ctx = talloc_named_const(tall_bsc_ctx, 0, "transaction");
-	tall_map_ctx = talloc_named_const(tall_bsc_ctx, 0, "trau_map_entry");
-	tall_upq_ctx = talloc_named_const(tall_bsc_ctx, 0, "trau_upq_entry");
-	tall_ctr_ctx = talloc_named_const(tall_bsc_ctx, 0, "counter");
+	tall_msgb_ctx = talloc_named_const(ctx_root, 0, "msgb");
+	tall_fle_ctx = talloc_named_const(ctx_root, 0, "bs11_file_list_entry");
+	tall_locop_ctx = talloc_named_const(ctx_root, 0, "loc_updating_oper");
+	tall_authciphop_ctx = talloc_named_const(ctx_root, 0, "auth_ciph_oper");
+	tall_gsms_ctx = talloc_named_const(ctx_root, 0, "sms");
+	tall_subscr_ctx = talloc_named_const(ctx_root, 0, "subscriber");
+	tall_sub_req_ctx = talloc_named_const(ctx_root, 0, "subscr_request");
+	tall_call_ctx = talloc_named_const(ctx_root, 0, "gsm_call");
+	tall_paging_ctx = talloc_named_const(ctx_root, 0, "paging_request");
+	tall_sigh_ctx = talloc_named_const(ctx_root, 0, "signal_handler");
+	tall_tqe_ctx = talloc_named_const(ctx_root, 0, "subch_txq_entry");
+	tall_trans_ctx = talloc_named_const(ctx_root, 0, "transaction");
+	tall_map_ctx = talloc_named_const(ctx_root, 0, "trau_map_entry");
+	tall_upq_ctx = talloc_named_const(ctx_root, 0, "trau_upq_entry");
+	tall_ctr_ctx = talloc_named_const(ctx_root, 0, "counter");
 }
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c
index 976aefa..67efe4f 100644
--- a/openbsc/src/osmo-nitb/bsc_hack.c
+++ b/openbsc/src/osmo-nitb/bsc_hack.c
@@ -243,8 +243,6 @@
 	osmo_timer_schedule(&bsc_gsmnet->subscr_expire_timer, EXPIRE_INTERVAL);
 }
 
-void talloc_ctx_init(void);
-
 extern int bsc_vty_go_parent(struct vty *vty);
 
 static struct vty_app_info vty_info = {
@@ -261,7 +259,7 @@
 	vty_info.copyright = openbsc_copyright;
 
 	tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc");
-	talloc_ctx_init();
+	talloc_ctx_init(tall_bsc_ctx);
 	on_dso_load_token();
 	on_dso_load_rrlp();
 	on_dso_load_ho_dec();

-- 
To view, visit https://gerrit.osmocom.org/923
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I168106599b788f586be0ff0af4699b9746c1b103
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list