diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2017-01-30 13:18:23 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2017-01-30 13:44:01 +0100 |
commit | 1b7b028e74d3b8786567bbd4795f167d0cef2c45 (patch) | |
tree | 37ca2ebbb78fe5feee87db357bc2fe8431638d86 | |
parent | 5b581ac6eba4adba0733cf4c20f41f4c7bcc2a3b (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
-rw-r--r-- | src/hlr.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -516,6 +516,7 @@ static int read_cb(struct osmo_gsup_conn *conn, struct msgb *msg) return 0; } +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); |