[asterisk-commits] russell: branch russell/chan_refcount r94975 - /team/russell/chan_refcount/apps/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Dec 27 13:56:02 CST 2007
Author: russell
Date: Thu Dec 27 13:56:02 2007
New Revision: 94975
URL: http://svn.digium.com/view/asterisk?view=rev&rev=94975
Log:
convert new app to new api
Modified:
team/russell/chan_refcount/apps/app_pickupchan.c
Modified: team/russell/chan_refcount/apps/app_pickupchan.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_pickupchan.c?view=diff&rev=94975&r1=94974&r2=94975
==============================================================================
--- team/russell/chan_refcount/apps/app_pickupchan.c (original)
+++ team/russell/chan_refcount/apps/app_pickupchan.c Thu Dec 27 13:56:02 2007
@@ -63,8 +63,9 @@
/*! \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)
{
- struct ast_channel *chan;
+ struct ast_channel *chan = NULL;
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
@@ -73,14 +74,15 @@
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))) {
+ iter = ast_channel_iterator_by_name_new(channame, strlen(channame));
+ while ((chan = ast_channel_iterator_next(iter))) {
if (!strncasecmp(chan->name, chkchan, strlen(chkchan)) && can_pickup(chan))
- return chan;
- ast_channel_unlock(chan);
+ break;
+ ast_channel_unref(chan);
}
- return NULL;
+ ast_channel_iterator_destroy(iter);
+
+ return chan;
}
/*! \brief Perform actual pickup between two channels */
@@ -118,10 +120,10 @@
return -1;
/* Just check that we are not picking up the SAME as target */
- if (chan->name != target->name && chan != target) {
+ if (chan->name != target->name && 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