[svn-commits] russell: branch russell/ast_channel_ao2 r183810 - /team/russell/ast_channel_a...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Mar 23 15:35:05 CDT 2009


Author: russell
Date: Mon Mar 23 15:35:01 2009
New Revision: 183810

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183810
Log:
Don't bother with the channel iterator if "count" was specified

Modified:
    team/russell/ast_channel_ao2/main/cli.c

Modified: team/russell/ast_channel_ao2/main/cli.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/main/cli.c?view=diff&rev=183810&r1=183809&r2=183810
==============================================================================
--- team/russell/ast_channel_ao2/main/cli.c (original)
+++ team/russell/ast_channel_ao2/main/cli.c Mon Mar 23 15:35:01 2009
@@ -789,7 +789,7 @@
 	int numchans = 0, concise = 0, verbose = 0, count = 0;
 	int fd, argc;
 	char **argv;
-	struct ast_channel_iterator *iter;
+	struct ast_channel_iterator *iter = NULL;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -832,11 +832,11 @@
 				"CallerID", "Duration", "Accountcode", "BridgedTo");
 	}
 
-	if (!(iter = ast_channel_iterator_all_new(0))) {
+	if (!count && !(iter = ast_channel_iterator_all_new(0))) {
 		return CLI_FAILURE;
 	}
 
-	for (; (c = ast_channel_iterator_next(iter)); ast_channel_unref(c)) {
+	for (; iter && (c = ast_channel_iterator_next(iter)); ast_channel_unref(c)) {
 		struct ast_channel *bc;
 		char durbuf[10] = "-";
 
@@ -886,12 +886,14 @@
 			}
 		}
 		ast_channel_unlock(c);
-		numchans++;
-	}
-
-	ast_channel_iterator_destroy(iter);
+	}
+
+	if (iter) {
+		ast_channel_iterator_destroy(iter);
+	}
 
 	if (!concise) {
+		numchans = ast_active_channels();
 		ast_cli(fd, "%d active channel%s\n", numchans, ESS(numchans));
 		if (option_maxcalls)
 			ast_cli(fd, "%d of %d max active call%s (%5.2f%% of capacity)\n",




More information about the svn-commits mailing list