Change in osmo-msc[master]: osmo-msc: Improve shutdown due to signal and print talloc report on exit

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Aug 14 06:53:49 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/10445 )

Change subject: osmo-msc: Improve shutdown due to signal and print talloc report on exit
......................................................................

osmo-msc: Improve shutdown due to signal and print talloc report on exit

Same as we do in osmo-hlr.

Change-Id: If6ea9171fd79f03251342f75987690b0d9dc3814
---
M src/osmo-msc/msc_main.c
1 file changed, 26 insertions(+), 5 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c
index aa06fb9..b1bb52a 100644
--- a/src/osmo-msc/msc_main.c
+++ b/src/osmo-msc/msc_main.c
@@ -110,6 +110,8 @@
 
 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 @@
 	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 @@
 		}
 	}
 
-	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;
 }

-- 
To view, visit https://gerrit.osmocom.org/10445
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If6ea9171fd79f03251342f75987690b0d9dc3814
Gerrit-Change-Number: 10445
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180814/1eaf16d6/attachment.htm>


More information about the gerrit-log mailing list