diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-08-13 16:29:50 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-08-13 16:30:28 +0200 |
commit | b874486e8e48f033204bfcc86871dd851266d440 (patch) | |
tree | b92bab038d5b60c93426eee7310ed1c31a30e57a /src/osmo-msc | |
parent | f02d17f75a417a40848f35fcd197144ccba803b1 (diff) |
osmo-msc: Improve shutdown due to signal and print talloc report on exit
Same as we do in osmo-hlr.
Change-Id: If6ea9171fd79f03251342f75987690b0d9dc3814
Diffstat (limited to 'src/osmo-msc')
-rw-r--r-- | src/osmo-msc/msc_main.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c index aa06fb924..b1bb52a63 100644 --- a/src/osmo-msc/msc_main.c +++ b/src/osmo-msc/msc_main.c @@ -110,6 +110,8 @@ static struct { static struct osmo_timer_list db_sync_timer; +static int quit = 0; + static void print_usage() { printf("Usage: osmo-msc\n"); @@ -233,10 +235,8 @@ static void signal_handler(int signal) switch (signal) { case SIGINT: case SIGTERM: - msc_network_shutdown(msc_network); - osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL); - sleep(3); - exit(0); + LOGP(DMSC, LOGL_NOTICE, "Terminating due to signal %d\n", signal); + quit++; break; case SIGABRT: osmo_generate_backtrace(); @@ -692,8 +692,29 @@ TODO: we probably want some of the _net_ ctrl commands from bsc_base_ctrl_cmds_i } } - while (1) { + while (!quit) { log_reset_context(); osmo_select_main(0); } + + msc_network_shutdown(msc_network); + osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL); + sleep(3); + + log_fini(); + + /** + * Report the heap state of root context, then free, + * so both ASAN and Valgrind are happy... + */ + talloc_report_full(tall_msc_ctx, stderr); + talloc_free(tall_msc_ctx); + + /** + * Report the heap state of NULL context, then free, + * so both ASAN and Valgrind are happy... + */ + talloc_report_full(NULL, stderr); + talloc_disable_null_tracking(); + return 0; } |