[asterisk-commits] russell: branch russell/chan_refcount r82355 - /team/russell/chan_refcount/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Sep 13 17:31:28 CDT 2007
Author: russell
Date: Thu Sep 13 17:31:28 2007
New Revision: 82355
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82355
Log:
convert the show channels handler
Modified:
team/russell/chan_refcount/main/cli.c
Modified: team/russell/chan_refcount/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/cli.c?view=diff&rev=82355&r1=82354&r2=82355
==============================================================================
--- team/russell/chan_refcount/main/cli.c (original)
+++ team/russell/chan_refcount/main/cli.c Thu Sep 13 17:31:28 2007
@@ -585,6 +585,7 @@
int numchans = 0, concise = 0, verbose = 0, count = 0;
int fd, argc;
char **argv;
+ struct ast_channel_iterator *iter;
switch (cmd) {
case CLI_INIT:
@@ -601,6 +602,7 @@
case CLI_GENERATE:
return NULL;
}
+
fd = a->fd;
argc = a->argc;
argv = a->argv;
@@ -625,9 +627,16 @@
"CallerID", "Duration", "Accountcode", "BridgedTo");
}
- while ((c = ast_channel_walk_locked(c)) != NULL) {
- struct ast_channel *bc = ast_bridged_channel(c);
+ if (!(iter = ast_channel_iterator_all_new()))
+ return CLI_FAILURE;
+
+ while ((c = ast_channel_iterator_next(iter))) {
+ struct ast_channel *bc;
char durbuf[10] = "-";
+
+ ast_channel_lock(c);
+
+ bc = ast_bridged_channel(c);
if (!count) {
if ((concise || verbose) && c->cdr && !ast_tvzero(c->cdr->start)) {
@@ -669,9 +678,15 @@
ast_cli(fd, FORMAT_STRING, c->name, locbuf, ast_state2str(c->_state), appdata);
}
}
+
numchans++;
+
ast_channel_unlock(c);
- }
+ ast_channel_unref(c);
+ }
+
+ iter = ast_channel_iterator_destroy(iter);
+
if (!concise) {
ast_cli(fd, "%d active channel%s\n", numchans, ESS(numchans));
if (option_maxcalls)
@@ -681,6 +696,7 @@
else
ast_cli(fd, "%d active call%s\n", ast_active_calls(), ESS(ast_active_calls()));
}
+
return CLI_SUCCESS;
#undef FORMAT_STRING
More information about the asterisk-commits
mailing list