[PATCH] osmo-hlr[master]: main: add and use root talloc 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
Mon Jan 30 12:44:56 UTC 2017


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

main: add and use root talloc ctx

Create hlr_ctx and pass on to DB and GSUP server code.
Add call msgb_talloc_ctx_init(hlr_ctx).

Instead of printing the entire talloc context on exit, just print the hlr_ctx
upon SIGUSR1 (like our other binaries do). Otherwise we will get pages of
talloc output on each program exit as soon as we add a VTY (next patch).

Change-Id: I3c64cb4ad7a681b88c7409296ad3afeb8000e2a4
---
M src/hlr.c
1 file changed, 7 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/05/1705/1

diff --git a/src/hlr.c b/src/hlr.c
index 674a58b..03c4435 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -516,6 +516,7 @@
 	return 0;
 }
 
+void *hlr_ctx = NULL;
 static struct osmo_gsup_server *gs;
 
 static void signal_hdlr(int signal)
@@ -526,11 +527,12 @@
 		osmo_gsup_server_destroy(gs);
 		db_close(g_dbc);
 		log_fini();
+		talloc_report_full(hlr_ctx, stderr);
 		exit(0);
 		break;
 	case SIGUSR1:
 		LOGP(DMAIN, LOGL_DEBUG, "Talloc Report due to SIGUSR1\n");
-		talloc_report_full(NULL, stderr);
+		talloc_report_full(hlr_ctx, stderr);
 		break;
 	}
 }
@@ -539,7 +541,8 @@
 {
 	int rc;
 
-	talloc_enable_leak_report_full();
+	hlr_ctx = talloc_named_const(NULL, 1, "OsmoHLR");
+	msgb_talloc_ctx_init(hlr_ctx, 0);
 
 	rc = osmo_init_logging(&hlr_log_info);
 	if (rc < 0) {
@@ -554,13 +557,13 @@
 		exit(1);
 	}
 
-	g_dbc = db_open(NULL, "hlr.db");
+	g_dbc = db_open(hlr_ctx, "hlr.db");
 	if (!g_dbc) {
 		LOGP(DMAIN, LOGL_FATAL, "Error opening database\n");
 		exit(1);
 	}
 
-	gs = osmo_gsup_server_create(NULL, NULL, 2222, read_cb);
+	gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb);
 	if (!gs) {
 		LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n");
 		exit(1);

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

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



More information about the gerrit-log mailing list