summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-04-07 18:44:14 +0200
committerHarald Welte <laforge@gnumonks.org>2017-04-10 11:48:35 +0200
commit07903bb2aded5472e617cfb30a1fdc0e9f5d6f99 (patch)
treee55f3fa66c210c37e9f96b5b27c9cb5256581347 /examples
parent30c2b89925232a2972e7b704e96446f6a511f4b2 (diff)
m3ua_example: Add talloc reporting
This can be used to check for memory leaks while running the example code. Change-Id: I87caa76a2be3c92c93e419242595107d744bad97
Diffstat (limited to 'examples')
-rw-r--r--examples/m3ua_example.c31
1 files changed, 26 insertions, 5 deletions
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;
@@ -37,6 +40,20 @@ static struct osmo_sccp_instance *sua_server_helper(void)
* 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,10 +80,14 @@ static struct vty_app_info vty_info = {
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();
osmo_fsm_log_addr(false);
@@ -85,11 +106,11 @@ int main(int argc, char **argv)
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) {