[asterisk-commits] russell: branch russell/chan_refcount r82589 - /team/russell/chan_refcount/apps/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 17 11:31:26 CDT 2007


Author: russell
Date: Mon Sep 17 11:31:25 2007
New Revision: 82589

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82589
Log:
make app_softhangup happy ... the whole tree builds now

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

Modified: team/russell/chan_refcount/apps/app_softhangup.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_softhangup.c?view=diff&rev=82589&r1=82588&r2=82589
==============================================================================
--- team/russell/chan_refcount/apps/app_softhangup.c (original)
+++ team/russell/chan_refcount/apps/app_softhangup.c Mon Sep 17 11:31:25 2007
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2007, Digium, Inc.
  *
  * Mark Spencer <markster at digium.com>
  *
@@ -63,16 +63,16 @@
 
 static int softhangup_exec(struct ast_channel *chan, void *data)
 {
-	struct ast_channel *c = NULL;
+	struct ast_channel *hangup_chan;
 	char *cut, *opts[0];
 	char name[AST_CHANNEL_NAME] = "", *parse;
 	struct ast_flags flags;
-	int lenmatch;
 	AST_DECLARE_APP_ARGS(args,
 		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");
 		return 0;
@@ -83,15 +83,18 @@
 
 	if (args.argc == 2)
 		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)) {
-		ast_copy_string(name, c->name, sizeof(name));
+	if (!(iter = ast_channel_iterator_by_name_new(args.channel, strlen(args.channel))))
+		return -1;
+
+	ast_autoservice_start(chan);
+
+	while ((hangup_chan = ast_channel_iterator_next(iter))) {
+		ast_channel_lock(hangup_chan);
+		ast_copy_string(name, hangup_chan->name, sizeof(name));
 		if (ast_test_flag(&flags, OPTION_ALL)) {
 			/* CAPI is set up like CAPI[foo/bar]/clcnt */ 
-			if (!strcmp(c->tech->type, "CAPI")) 
+			if (!strcmp(hangup_chan->tech->type, "CAPI")) 
 				cut = strrchr(name, '/');
 			/* Basically everything else is Foo/Bar-Z */
 			else
@@ -101,15 +104,21 @@
 				*cut = 0;
 		}
 		if (!strcasecmp(name, args.channel)) {
-			ast_log(LOG_WARNING, "Soft hanging %s up.\n", c->name);
-			ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
+			ast_log(LOG_WARNING, "Soft hanging %s up.\n", hangup_chan->name);
+			ast_softhangup(hangup_chan, AST_SOFTHANGUP_EXPLICIT);
 			if (!ast_test_flag(&flags, OPTION_ALL)) {
-				ast_mutex_unlock(&c->lock);
+				ast_channel_unlock(hangup_chan);
+				ast_channel_unref(hangup_chan);
 				break;
 			}
 		}
-		ast_mutex_unlock(&c->lock);
+		ast_channel_unlock(hangup_chan);
+		ast_channel_unref(hangup_chan);
 	}
+
+	ast_channel_iterator_destroy(iter);
+
+	ast_autoservice_stop(chan);
 
 	return 0;
 }




More information about the asterisk-commits mailing list