[Asterisk-code-review] res pjsip log forwarder.c: Add CLI "pjsip dump endpt [details]" (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Fri Jan 15 10:42:30 CST 2016


Richard Mudgett has uploaded a new change for review.

  https://gerrit.asterisk.org/2022

Change subject: res_pjsip_log_forwarder.c: Add CLI "pjsip dump endpt [details]"
......................................................................

res_pjsip_log_forwarder.c: Add CLI "pjsip dump endpt [details]"

Dump the res_pjsip endpt internals.

Warning: PJPROJECT documents that the function used by this CLI command
may cause a crash when asking for details because it tries to access all
active memory pools.

Change-Id: If2d98a3641c9873364d1daaad971376311aef3cb
---
M res/res_pjsip_log_forwarder.c
1 file changed, 47 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/22/2022/1

diff --git a/res/res_pjsip_log_forwarder.c b/res/res_pjsip_log_forwarder.c
index 7a71280..68f2e74 100644
--- a/res/res_pjsip_log_forwarder.c
+++ b/res/res_pjsip_log_forwarder.c
@@ -47,6 +47,7 @@
 #include "asterisk/logger.h"
 #include "asterisk/module.h"
 #include "asterisk/cli.h"
+#include "asterisk/res_pjsip.h"
 
 static pj_log_func *log_cb_orig;
 static unsigned decor_orig;
@@ -139,7 +140,53 @@
 	return CLI_SUCCESS;
 }
 
+static int do_pjsip_dump_endpt(void *v_a)
+{
+	struct ast_cli_args *a = v_a;
+
+	show_buildopts.thread = pthread_self();
+	show_buildopts.fd = a->fd;
+	pjsip_endpt_dump(ast_sip_get_pjsip_endpoint(), a->argc == 4 ? PJ_TRUE : PJ_FALSE);
+	show_buildopts.fd = -1;
+	show_buildopts.thread = AST_PTHREADT_NULL;
+
+	return 0;
+}
+
+static char *handle_pjsip_dump_endpt(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch(cmd) {
+	case CLI_INIT:
+		e->command = "pjsip dump endpt [details]";
+		e->usage =
+			"Usage: pjsip dump endpt [details]\n"
+			"       Dump the res_pjsip endpt internals.\n"
+			"\n"
+			"Warning: PJPROJECT documents that the function used by this\n"
+			"CLI command may cause a crash when asking for details because\n"
+			"it tries to access all active memory pools.\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+
+	if (4 < a->argc
+		|| (a->argc == 4 && strcasecmp(a->argv[3], "details"))) {
+		return CLI_SHOWUSAGE;
+	}
+
+	/* Protect from other CLI instances trying to do this at the same time. */
+	ast_mutex_lock(&show_buildopts_lock);
+
+	ast_sip_push_task_synchronous(NULL, do_pjsip_dump_endpt, a);
+
+	ast_mutex_unlock(&show_buildopts_lock);
+
+	return CLI_SUCCESS;
+}
+
 static struct ast_cli_entry pjsip_cli[] = {
+	AST_CLI_DEFINE(handle_pjsip_dump_endpt, "Dump the res_pjsip endpt internals"),
 	AST_CLI_DEFINE(handle_pjsip_show_buildopts, "Show the compiled config of pjproject in use"),
 };
 

-- 
To view, visit https://gerrit.asterisk.org/2022
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2d98a3641c9873364d1daaad971376311aef3cb
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list