aboutsummaryrefslogtreecommitdiffstats
path: root/src/hlr.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-01-30 13:18:23 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-02-01 04:20:51 +0100
commitca43e30be3a27d573e24f85452415b0b6bcefa67 (patch)
tree527200f707699bed4571b67fdb603ee1791abd1e /src/hlr.c
parent5b581ac6eba4adba0733cf4c20f41f4c7bcc2a3b (diff)
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
Diffstat (limited to 'src/hlr.c')
-rw-r--r--src/hlr.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/hlr.c b/src/hlr.c
index 674a58b..bf0655e 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -516,6 +516,7 @@ static int read_cb(struct osmo_gsup_conn *conn, struct msgb *msg)
return 0;
}
+static void *hlr_ctx = NULL;
static struct osmo_gsup_server *gs;
static void signal_hdlr(int signal)
@@ -526,11 +527,12 @@ static void signal_hdlr(int signal)
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 main(int argc, char **argv)
{
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 @@ int main(int argc, char **argv)
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);