[MERGED] libosmo-sccp[master]: m3ua_example: Add talloc reporting

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
Mon Apr 10 11:27:00 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: m3ua_example: Add talloc reporting
......................................................................


m3ua_example: Add talloc reporting

This can be used to check for memory leaks while running the example
code.

Change-Id: I87caa76a2be3c92c93e419242595107d744bad97
---
M examples/m3ua_example.c
1 file changed, 26 insertions(+), 5 deletions(-)

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



diff --git a/examples/m3ua_example.c b/examples/m3ua_example.c
index d7b1fc2..07de7f3 100644
--- a/examples/m3ua_example.c
+++ b/examples/m3ua_example.c
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
+#include <signal.h>
 
 #include <osmocom/core/select.h>
 #include <osmocom/core/utils.h>
@@ -20,6 +21,8 @@
 
 #include "internal.h"
 
+static struct osmo_sccp_instance *g_sccp;
+
 static struct osmo_sccp_instance *sua_server_helper(void)
 {
 	struct osmo_sccp_instance *sccp;
@@ -36,6 +39,20 @@
 /***********************************************************************
  * Initialization
  ***********************************************************************/
+
+static void signal_handler(int signal)
+{
+	fprintf(stdout, "signal %d received\n", signal);
+
+	switch (signal) {
+	case SIGUSR1:
+		talloc_report_full(osmo_sccp_get_ss7(g_sccp), stderr);
+		break;
+	case SIGUSR2:
+		talloc_report_full(NULL, stderr);
+		break;
+	}
+}
 
 static const struct log_info_cat log_info_cat[] = {
 };
@@ -63,9 +80,13 @@
 
 int main(int argc, char **argv)
 {
-	struct osmo_sccp_instance *sccp;
 	bool client;
 	int rc;
+
+	talloc_enable_leak_report_full();
+
+	signal(SIGUSR1, &signal_handler);
+	signal(SIGUSR2, &signal_handler);
 
 	init_logging();
 	osmo_ss7_init();
@@ -85,11 +106,11 @@
 
 
 	if (client) {
-		sccp = osmo_sccp_simple_client(NULL, "client", 23, OSMO_SS7_ASP_PROT_M3UA, 0, M3UA_PORT, "127.0.0.2");
-		sccp_test_user_vty_install(sccp, OSMO_SCCP_SSN_BSC_BSSAP);
+		g_sccp = osmo_sccp_simple_client(NULL, "client", 23, OSMO_SS7_ASP_PROT_M3UA, 0, M3UA_PORT, "127.0.0.2");
+		sccp_test_user_vty_install(g_sccp, OSMO_SCCP_SSN_BSC_BSSAP);
 	} else {
-		sccp = sua_server_helper();
-		sccp_test_server_init(sccp);
+		g_sccp = sua_server_helper();
+		sccp_test_server_init(g_sccp);
 	}
 
 	while (1) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I87caa76a2be3c92c93e419242595107d744bad97
Gerrit-PatchSet: 5
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list