[asterisk-commits] russell: branch russell/ast_channel_ao2 r174039 - /team/russell/ast_channel_a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 6 12:33:17 CST 2009


Author: russell
Date: Fri Feb  6 12:33:17 2009
New Revision: 174039

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=174039
Log:
Convert app_softhangup

Modified:
    team/russell/ast_channel_ao2/apps/app_softhangup.c

Modified: team/russell/ast_channel_ao2/apps/app_softhangup.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/apps/app_softhangup.c?view=diff&rev=174039&r1=174038&r2=174039
==============================================================================
--- team/russell/ast_channel_ao2/apps/app_softhangup.c (original)
+++ team/russell/ast_channel_ao2/apps/app_softhangup.c Fri Feb  6 12:33:17 2009
@@ -80,6 +80,7 @@
 		AST_APP_ARG(channel);
 		AST_APP_ARG(options);
 	);
+	struct ast_channel_iterator *iter;
 	
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "SoftHangup requires an argument (Technology/resource)\n");
@@ -93,9 +94,12 @@
 		ast_app_parse_options(app_opts, &flags, opts, args.options);
 	lenmatch = strlen(args.channel);
 
-	for (c = ast_walk_channel_by_name_prefix_locked(NULL, args.channel, lenmatch);
-		 c;
-		 c = ast_walk_channel_by_name_prefix_locked(c, args.channel, lenmatch)) {
+	if (!(iter = ast_channel_iterator_by_name_new(0, args.channel, lenmatch))) {
+		return -1;
+	}
+
+	while ((c = ast_channel_iterator_next(iter))) {
+		ast_channel_lock(c);
 		ast_copy_string(name, c->name, sizeof(name));
 		if (ast_test_flag(&flags, OPTION_ALL)) {
 			/* CAPI is set up like CAPI[foo/bar]/clcnt */ 
@@ -113,11 +117,15 @@
 			ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
 			if (!ast_test_flag(&flags, OPTION_ALL)) {
 				ast_channel_unlock(c);
+				c = ast_channel_unref(c);
 				break;
 			}
 		}
 		ast_channel_unlock(c);
+		c = ast_channel_unref(c);
 	}
+
+	ast_channel_iterator_destroy(iter);
 
 	return 0;
 }




More information about the asterisk-commits mailing list