aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-03-22 15:56:49 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-03-22 17:06:05 +0100
commitc01e90933fef6449f64db65a63590a6507bae34a (patch)
tree8757bfb928e630e32f40272509479c4137f161f0 /src
parent6a8b9c70fceba57f624c9c23c97cbb27389e4584 (diff)
dissolve libcommon: move talloc ctx into msc_main.c, drop talloc_ctx.c
Drop tall_bsc_ctx; in mncc_sock_init(), talloc the mncc_sock_state from gsm_network. In tests or utils, move from using an extern tall_bsc_ctx to a local root context pointer. Change-Id: I92c252be1d1e7634f1653de47d37c99d77d9501c
Diffstat (limited to 'src')
-rw-r--r--src/libcommon/Makefile.am1
-rw-r--r--src/libcommon/gsup_client.c5
-rw-r--r--src/libcommon/gsup_test_client.c4
-rw-r--r--src/libcommon/talloc_ctx.c38
-rw-r--r--src/libmsc/mncc_sock.c2
-rw-r--r--src/libvlr/vlr.c2
-rw-r--r--src/osmo-msc/msc_main.c10
7 files changed, 15 insertions, 47 deletions
diff --git a/src/libcommon/Makefile.am b/src/libcommon/Makefile.am
index 5bd1c2f94..dff0be35d 100644
--- a/src/libcommon/Makefile.am
+++ b/src/libcommon/Makefile.am
@@ -23,7 +23,6 @@ libcommon_a_SOURCES = \
gsm_data.c \
gsup_client.c \
oap_client.c \
- talloc_ctx.c \
gsm_subscriber_base.c \
$(NULL)
diff --git a/src/libcommon/gsup_client.c b/src/libcommon/gsup_client.c
index 0335e210b..9051b3197 100644
--- a/src/libcommon/gsup_client.c
+++ b/src/libcommon/gsup_client.c
@@ -265,7 +265,8 @@ static void start_test_procedure(struct gsup_client *gsupc)
gsup_client_send_ping(gsupc);
}
-struct gsup_client *gsup_client_create(const char *unit_name,
+struct gsup_client *gsup_client_create(void *talloc_ctx,
+ const char *unit_name,
const char *ip_addr,
unsigned int tcp_port,
gsup_client_read_cb_t read_cb,
@@ -274,7 +275,7 @@ struct gsup_client *gsup_client_create(const char *unit_name,
struct gsup_client *gsupc;
int rc;
- gsupc = talloc_zero(tall_bsc_ctx, struct gsup_client);
+ gsupc = talloc_zero(talloc_ctx, struct gsup_client);
OSMO_ASSERT(gsupc);
/* struct ipaccess_unit has a non-const unit_name, so let's copy to be
diff --git a/src/libcommon/gsup_test_client.c b/src/libcommon/gsup_test_client.c
index 3e88689e7..add98e47a 100644
--- a/src/libcommon/gsup_test_client.c
+++ b/src/libcommon/gsup_test_client.c
@@ -275,8 +275,6 @@ static void sig_cb(int sig)
}
}
-void *tall_bsc_ctx = NULL;
-
/* default categories */
static struct log_info_cat default_categories[] = {
};
@@ -294,7 +292,7 @@ int main(int argc, char **argv)
osmo_init_logging(&gsup_test_client_log_info);
- g_gc = gsup_client_create("GSUPTEST", server_host, server_port,
+ g_gc = gsup_client_create(NULL, "GSUPTEST", server_host, server_port,
gsupc_read_cb, NULL);
diff --git a/src/libcommon/talloc_ctx.c b/src/libcommon/talloc_ctx.c
deleted file mode 100644
index ccda0d0f2..000000000
--- a/src/libcommon/talloc_ctx.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* OpenBSC allocation contexts initialization code */
-/* (C) 2011-2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <osmocom/core/talloc.h>
-#include <osmocom/core/msgb.h>
-
-extern void *tall_bsc_ctx;
-extern void *tall_gsms_ctx;
-extern void *tall_subscr_ctx;
-extern void *tall_call_ctx;
-extern void *tall_sigh_ctx;
-extern void *tall_trans_ctx;
-
-void talloc_ctx_init(void *ctx_root)
-{
- msgb_talloc_ctx_init(ctx_root, 0);
- tall_gsms_ctx = talloc_named_const(ctx_root, 0, "sms");
- tall_subscr_ctx = talloc_named_const(ctx_root, 0, "subscriber");
- tall_call_ctx = talloc_named_const(ctx_root, 0, "gsm_call");
- tall_sigh_ctx = talloc_named_const(ctx_root, 0, "signal_handler");
- tall_trans_ctx = talloc_named_const(ctx_root, 0, "transaction");
-}
diff --git a/src/libmsc/mncc_sock.c b/src/libmsc/mncc_sock.c
index 14613ca2c..74ea9d20c 100644
--- a/src/libmsc/mncc_sock.c
+++ b/src/libmsc/mncc_sock.c
@@ -284,7 +284,7 @@ int mncc_sock_init(struct gsm_network *net, const char *sock_path)
struct osmo_fd *bfd;
int rc;
- state = talloc_zero(tall_bsc_ctx, struct mncc_sock_state);
+ state = talloc_zero(net, struct mncc_sock_state);
if (!state)
return -ENOMEM;
diff --git a/src/libvlr/vlr.c b/src/libvlr/vlr.c
index f73eeb4f8..01e7ee104 100644
--- a/src/libvlr/vlr.c
+++ b/src/libvlr/vlr.c
@@ -1040,7 +1040,7 @@ int vlr_start(const char *gsup_unit_name, struct vlr_instance *vlr,
{
OSMO_ASSERT(vlr);
- vlr->gsup_client = gsup_client_create(gsup_unit_name,
+ vlr->gsup_client = gsup_client_create(vlr, gsup_unit_name,
gsup_server_addr_str,
gsup_server_port,
&vlr_gsupc_read_cb, NULL);
diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c
index 1cf264274..2b1a8c753 100644
--- a/src/osmo-msc/msc_main.c
+++ b/src/osmo-msc/msc_main.c
@@ -513,6 +513,10 @@ const struct log_info log_info = {
.num_cat = ARRAY_SIZE(msc_default_categories),
};
+extern void *tall_gsms_ctx;
+extern void *tall_call_ctx;
+extern void *tall_trans_ctx;
+
int main(int argc, char **argv)
{
int rc;
@@ -520,9 +524,13 @@ int main(int argc, char **argv)
msc_vty_info.copyright = osmomsc_copyright;
tall_msc_ctx = talloc_named_const(NULL, 1, "osmo_msc");
- talloc_ctx_init(tall_msc_ctx);
msc_vty_info.tall_ctx = tall_msc_ctx;
+ msgb_talloc_ctx_init(tall_msc_ctx, 0);
+ tall_gsms_ctx = talloc_named_const(tall_msc_ctx, 0, "sms");
+ tall_call_ctx = talloc_named_const(tall_msc_ctx, 0, "gsm_call");
+ tall_trans_ctx = talloc_named_const(tall_msc_ctx, 0, "transaction");
+
osmo_init_logging(&log_info);
osmo_stats_init(tall_msc_ctx);