diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-04-01 16:54:40 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2018-04-01 16:57:42 +0200 |
commit | 42f2d61ac9d4be3ffc5ece501de8d0ac25f0ca14 (patch) | |
tree | 02cc70f4081ca4f86ce58760f533d22f3669c638 /src | |
parent | e6e4898027f45ea48dc1adf0cf4ea558a1960f4f (diff) |
use osmo_init_logging2() with proper talloc ctx
There is a duality of initialization: early_init() in bts.cpp wants to init
logging even before static instances get initialized. Make sure that
tall_pcu_ctx is initialized during early_init() as well. There is a build
context that does not seem to include bts.cpp (osmo-pcu-remote), so to be sure,
init tall_pcu_ctx as NULL and both in early_init() as well as pcu_main.cpp,
init both tall_pcu_ctx and logging if it is still NULL.
Change-Id: I2199b62d0270bd35dec2283e8f5b364b7c63915b
Diffstat (limited to 'src')
-rw-r--r-- | src/bts.cpp | 5 | ||||
-rw-r--r-- | src/pcu_main.cpp | 13 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/bts.cpp b/src/bts.cpp index 47607df9..b6d0d0cf 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -59,7 +59,10 @@ extern "C" { * require logging already to be initialized. */ __attribute__((constructor)) static void early_init(void) { - osmo_init_logging(&gprs_log_info); + if (!tall_pcu_ctx) { + tall_pcu_ctx = talloc_named_const(NULL, 1, "Osmo-PCU context"); + osmo_init_logging2(tall_pcu_ctx, &gprs_log_info); + } } } diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp index 84ade6f3..5b1b1be3 100644 --- a/src/pcu_main.cpp +++ b/src/pcu_main.cpp @@ -56,7 +56,7 @@ bool spoof_mnc_3_digits = false; static int config_given = 0; static char *config_file = strdup("osmo-pcu.cfg"); extern struct vty_app_info pcu_vty_info; -void *tall_pcu_ctx; +void *tall_pcu_ctx = NULL; extern void *bv_tall_ctx; static int quit = 0; static int rt_prio = -1; @@ -181,9 +181,13 @@ int main(int argc, char *argv[]) struct gprs_rlcmac_bts *bts; int rc; - tall_pcu_ctx = talloc_named_const(NULL, 1, "Osmo-PCU context"); - if (!tall_pcu_ctx) - return -ENOMEM; + /* tall_pcu_ctx may already have been initialized in bts.cpp during early_init(). */ + if (!tall_pcu_ctx) { + tall_pcu_ctx = talloc_named_const(NULL, 1, "Osmo-PCU context"); + if (!tall_pcu_ctx) + return -ENOMEM; + osmo_init_logging2(tall_pcu_ctx, &gprs_log_info); + } bts = bts_main_data(); bts->fc_interval = 1; @@ -259,7 +263,6 @@ int main(int argc, char *argv[]) msgb_talloc_ctx_init(tall_pcu_ctx, 0); - osmo_init_logging(&gprs_log_info); osmo_stats_init(tall_pcu_ctx); rate_ctr_init(tall_pcu_ctx); gprs_ns_set_log_ss(DNS); |