[asterisk-commits] russell: branch russell/chan_refcount r82562 - /team/russell/chan_refcount/apps/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 17 00:52:10 CDT 2007
Author: russell
Date: Mon Sep 17 00:52:09 2007
New Revision: 82562
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82562
Log:
convert app_chanspy
Modified:
team/russell/chan_refcount/apps/app_chanspy.c
Modified: team/russell/chan_refcount/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_chanspy.c?view=diff&rev=82562&r1=82561&r2=82562
==============================================================================
--- team/russell/chan_refcount/apps/app_chanspy.c (original)
+++ team/russell/chan_refcount/apps/app_chanspy.c Mon Sep 17 00:52:09 2007
@@ -367,28 +367,6 @@
return running;
}
-static struct ast_channel *next_channel(const struct ast_channel *last, const char *spec,
- const char *exten, const char *context)
-{
- struct ast_channel *this;
-
- redo:
- if (spec)
- this = ast_walk_channel_by_name_prefix_locked(last, spec, strlen(spec));
- else if (exten)
- this = ast_walk_channel_by_exten_locked(last, exten, context);
- else
- this = ast_channel_walk_locked(last);
-
- if (this) {
- ast_channel_unlock(this);
- if (!strncmp(this->name, "Zap/pseudo", 10))
- goto redo;
- }
-
- return this;
-}
-
static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
int volfactor, const int fd, const char *mygroup, const char *spec,
const char *exten, const char *context)
@@ -402,6 +380,7 @@
int res;
char *ptr;
int num;
+ struct ast_channel_iterator *iter = NULL;
if (ast_test_flag(flags, OPTION_EXIT)) {
const char *c;
@@ -459,9 +438,25 @@
waitms = 100;
peer = prev = next = NULL;
- for (peer = next_channel(peer, spec, exten, context);
+ if (spec)
+ iter = ast_channel_iterator_by_name_new(spec, strlen(spec));
+ else if (exten)
+ iter = ast_channel_iterator_by_exten_new(exten, context);
+ else
+ iter = ast_channel_iterator_all_new();
+
+ if (!iter)
+ goto exit;
+
+ for (peer = ast_channel_iterator_next(iter);
peer;
- prev = peer, peer = next ? next : next_channel(peer, spec, exten, context), next = NULL) {
+ prev = peer,
+ (next != peer) ? ast_channel_unref(peer) : NULL,
+ peer = next ? next : ast_channel_iterator_next(iter), next = NULL) {
+
+ /* The 'prev' pointer _must_ not be dereferenced in this loop, as
+ * the reference to it has been released already. */
+
const char *group;
int igrp = !mygroup;
char *groups[25];
@@ -531,9 +526,7 @@
goto exit;
} else if (res > 1 && spec) {
snprintf(nameprefix, AST_NAME_STRLEN, "%s/%d", spec, res);
- if ((next = ast_get_channel_by_name_prefix_locked(nameprefix, strlen(nameprefix)))) {
- ast_channel_unlock(next);
- } else {
+ if (!(next = ast_channel_get_by_name_prefix(nameprefix, strlen(nameprefix)))) {
/* stay on this channel */
next = peer;
}
More information about the asterisk-commits
mailing list