[asterisk-commits] russell: branch russell/chan_refcount r115264 - /team/russell/chan_refcount/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 2 21:40:05 CDT 2008


Author: russell
Date: Fri May  2 21:40:04 2008
New Revision: 115264

URL: http://svn.digium.com/view/asterisk?view=rev&rev=115264
Log:
Convert app_directed_pickup to the new API.  The branch is compiling again, yay.

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

Modified: team/russell/chan_refcount/apps/app_directed_pickup.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_directed_pickup.c?view=diff&rev=115264&r1=115263&r2=115264
==============================================================================
--- team/russell/chan_refcount/apps/app_directed_pickup.c (original)
+++ team/russell/chan_refcount/apps/app_directed_pickup.c Fri May  2 21:40:04 2008
@@ -97,10 +97,11 @@
 }
 
 /*! \brief Helper Function to walk through ALL channels checking NAME and STATE */
-static struct ast_channel *my_ast_get_channel_by_name_locked(char *channame)
+static struct ast_channel *get_channel_by_name(char *channame)
 {
 	struct ast_channel *chan;
 	char *chkchan = alloca(strlen(channame) + 2);
+	struct ast_channel_iterator *iter;
 
 	/* need to append a '-' for the comparison so we check full channel name,
 	 * i.e SIP/hgc- , use a temporary variable so original stays the same for
@@ -109,13 +110,20 @@
 	strcpy(chkchan, channame);
 	strcat(chkchan, "-");
 
-	for (chan = ast_walk_channel_by_name_prefix_locked(NULL, channame, strlen(channame));
-		 chan;
-		 chan = ast_walk_channel_by_name_prefix_locked(chan, channame, strlen(channame))) {
-		if (!strncasecmp(chan->name, chkchan, strlen(chkchan)) && can_pickup(chan))
+	if (!(iter = ast_channel_iterator_by_name_new(0, channame, strlen(channame)))) {
+		return NULL;
+	}
+
+	while ((chan = ast_channel_iterator_next(iter))) {
+		if (!strncasecmp(chan->name, chkchan, strlen(chkchan)) && can_pickup(chan)) {
 			return chan;
-		ast_channel_unlock(chan);
-	}
+		}
+
+		ast_channel_unref(chan);
+	}
+
+	ast_channel_iterator_destroy(iter);
+
 	return NULL;
 }
 
@@ -125,14 +133,16 @@
 	int res = 0;
 	struct ast_channel *target;
 
-	if (!(target = my_ast_get_channel_by_name_locked(pickup)))
-		return -1;
+	if (!(target = get_channel_by_name(pickup))) {
+		return -1;
+	}
 
 	/* Just check that we are not picking up the SAME as target */
-	if (chan->name != target->name && chan != target) {
+	if (chan != target) {
 		res = pickup_do(chan, target);
-		ast_channel_unlock(target);
-	}
+	}
+
+	ast_channel_unref(target);
 
 	return res;
 }




More information about the asterisk-commits mailing list