[asterisk-dev] Channel lock in "core show channel" CLI command ?
Pavel Troller
patrol at sinus.cz
Thu Sep 15 12:18:35 CDT 2011
Hi!
I've made a patch for 1.8 branch, which is attached. I think it's just a few
lines. Maybe the fixed static buffers are not the best solution, it was just a
proof of concept, and it works here perfectly. Now you can do everything during
the command, including Scroll Lock, and it has no impact on the channel
itself (btw a Scroll Lock/Ctrl-S is a Good Thing, if the command output is
really long).
With regards, Pavel
-------------- next part --------------
Index: cli.c
===================================================================
--- cli.c (revision 334948)
+++ cli.c (working copy)
@@ -1387,13 +1387,14 @@
struct timeval now;
struct ast_str *out = ast_str_thread_get(&ast_str_thread_global_buf, 16);
char cdrtime[256];
- char nf[256], wf[256], rf[256];
+ char nf[256], wf[256], rf[256], output1[4096], output2[4096], output3[4096];
struct ast_str *write_transpath = ast_str_alloca(256);
struct ast_str *read_transpath = ast_str_alloca(256);
long elapsed_seconds=0;
int hour=0, min=0, sec=0;
#ifdef CHANNEL_TRACE
int trace_enabled;
+ char output4[64], output5[4096];
#endif
switch (cmd) {
@@ -1430,7 +1431,7 @@
strcpy(cdrtime, "N/A");
}
- ast_cli(a->fd,
+ snprintf(output1, sizeof(output1),
" -- General --\n"
" Name: %s\n"
" Type: %s\n"
@@ -1490,23 +1491,32 @@
(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));
+ snprintf(output2, sizeof(output2), " Variables:\n%s\n", ast_str_buffer(out));
+ } else {
+ output2[0]=0;
}
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));
+ snprintf(output3, sizeof(output3), " CDR Variables:\n%s\n", ast_str_buffer(out));
+ } else {
+ output3[0]=0;
}
-
#ifdef CHANNEL_TRACE
trace_enabled = ast_channel_trace_is_enabled(c);
- ast_cli(a->fd, " Context Trace: %s\n", trace_enabled ? "Enabled" : "Disabled");
+ snprintf(output4, sizeof(output4), " 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));
+ snprintf(output5, sizeof(output5), " Trace:\n%s\n", ast_str_buffer(out));
+ else
+ output5[0]=0;
#endif
ast_channel_unlock(c);
c = ast_channel_unref(c);
+ ast_cli(a->fd, "%s%s%s", output1, output2, output3);
+#ifdef CHANNEL_TRACE
+ ast_cli(a->fd, "%s%s", output4, output5);
+#endif
return CLI_SUCCESS;
}
More information about the asterisk-dev
mailing list