[asterisk-commits] rmudgett: trunk r344663 - in /trunk: ./ main/cli.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Nov 11 12:02:55 CST 2011
Author: rmudgett
Date: Fri Nov 11 12:02:52 2011
New Revision: 344663
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=344663
Log:
Make CLI "core show channel" not hold the channel lock during console output.
Holding the channel lock while the CLI "core show channel" command is
executing can slow down the system. It could block the system if the
console output is halted or paused.
* Made capture the CLI "core show channel" output into a buffer to be
output after the channel is unlocked.
* Removed use of C++ keyword as a variable name. out renamed to obuf.
* Checked allocation of obuf for failure so will not crash.
(closes issue ASTERISK-18571)
Reported by: Pavel Troller
Tested by: rmudgett
........
Merged revisions 344661 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 344662 from http://svn.asterisk.org/svn/asterisk/branches/10
Modified:
trunk/ (props changed)
trunk/main/cli.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.
Modified: trunk/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cli.c?view=diff&rev=344663&r1=344662&r2=344663
==============================================================================
--- trunk/main/cli.c (original)
+++ trunk/main/cli.c Fri Nov 11 12:02:52 2011
@@ -1385,11 +1385,12 @@
{
struct ast_channel *c=NULL;
struct timeval now;
- struct ast_str *out = ast_str_thread_get(&ast_str_thread_global_buf, 16);
char cdrtime[256];
char nf[256];
struct ast_str *write_transpath = ast_str_alloca(256);
struct ast_str *read_transpath = ast_str_alloca(256);
+ struct ast_str *obuf;/*!< Buffer for variable, CDR variable, and trace output. */
+ struct ast_str *output;/*!< Accumulation buffer for all output. */
long elapsed_seconds=0;
int hour=0, min=0, sec=0;
#ifdef CHANNEL_TRACE
@@ -1416,6 +1417,15 @@
if (!(c = ast_channel_get_by_name(a->argv[3]))) {
ast_cli(a->fd, "%s is not a known channel\n", a->argv[3]);
return CLI_SUCCESS;
+ }
+
+ obuf = ast_str_thread_get(&ast_str_thread_global_buf, 16);
+ if (!obuf) {
+ return CLI_FAILURE;
+ }
+ output = ast_str_create(8192);
+ if (!output) {
+ return CLI_FAILURE;
}
ast_channel_lock(c);
@@ -1430,7 +1440,7 @@
strcpy(cdrtime, "N/A");
}
- ast_cli(a->fd,
+ ast_str_append(&output, 0,
" -- General --\n"
" Name: %s\n"
" Type: %s\n"
@@ -1489,24 +1499,28 @@
( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
(ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
- if (pbx_builtin_serialize_variables(c, &out)) {
- ast_cli(a->fd," Variables:\n%s\n", ast_str_buffer(out));
- }
-
- if (c->cdr && ast_cdr_serialize_variables(c->cdr, &out, '=', '\n', 1)) {
- ast_cli(a->fd," CDR Variables:\n%s\n", ast_str_buffer(out));
+ if (pbx_builtin_serialize_variables(c, &obuf)) {
+ ast_str_append(&output, 0, " Variables:\n%s\n", ast_str_buffer(obuf));
+ }
+
+ if (c->cdr && ast_cdr_serialize_variables(c->cdr, &obuf, '=', '\n', 1)) {
+ ast_str_append(&output, 0, " CDR Variables:\n%s\n", ast_str_buffer(obuf));
}
#ifdef CHANNEL_TRACE
trace_enabled = ast_channel_trace_is_enabled(c);
- ast_cli(a->fd, " Context Trace: %s\n", trace_enabled ? "Enabled" : "Disabled");
- if (trace_enabled && ast_channel_trace_serialize(c, &out))
- ast_cli(a->fd, " Trace:\n%s\n", ast_str_buffer(out));
+ ast_str_append(&output, 0, " Context Trace: %s\n",
+ trace_enabled ? "Enabled" : "Disabled");
+ if (trace_enabled && ast_channel_trace_serialize(c, &obuf)) {
+ ast_str_append(&output, 0, " Trace:\n%s\n", ast_str_buffer(obuf));
+ }
#endif
ast_channel_unlock(c);
c = ast_channel_unref(c);
+ ast_cli(a->fd, "%s", ast_str_buffer(output));
+ ast_free(output);
return CLI_SUCCESS;
}
More information about the asterisk-commits
mailing list