aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-06-06 02:29:18 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-06-06 02:29:18 +0000
commit7b1b9f53ef47abd82c6faba12f4adcf721e622da (patch)
treebe967c9ab3099202d13219196b5f17284a939e78 /apps
parentd39208dd35ce0ead92bf6a4b21361f3d13759589 (diff)
more efficient (and understandable) ast_channel_walk_locked, and vastly more efficient ast_channel_by_name_locked (bug #4265)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5853 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rwxr-xr-xapps/app_groupcount.c4
-rwxr-xr-xapps/app_setcdruserfield.c8
-rwxr-xr-xapps/app_softhangup.c1
-rwxr-xr-xapps/app_zapscan.c10
4 files changed, 4 insertions, 19 deletions
diff --git a/apps/app_groupcount.c b/apps/app_groupcount.c
index f7ac15763..d17521001 100755
--- a/apps/app_groupcount.c
+++ b/apps/app_groupcount.c
@@ -174,9 +174,8 @@ static int group_show_channels(int fd, int argc, char *argv[])
havepattern = 1;
}
- c = ast_channel_walk_locked(NULL);
ast_cli(fd, FORMAT_STRING, "Channel", "Group", "Category");
- while(c) {
+ while ( (c = ast_channel_walk_locked(c)) != NULL) {
headp=&c->varshead;
AST_LIST_TRAVERSE(headp,current,entries) {
if (!strncmp(ast_var_name(current), GROUP_CATEGORY_PREFIX "_", strlen(GROUP_CATEGORY_PREFIX) + 1)) {
@@ -194,7 +193,6 @@ static int group_show_channels(int fd, int argc, char *argv[])
}
numchans++;
ast_mutex_unlock(&c->lock);
- c = ast_channel_walk_locked(c);
}
if (havepattern)
diff --git a/apps/app_setcdruserfield.c b/apps/app_setcdruserfield.c
index 4684fdd8b..7e820db12 100755
--- a/apps/app_setcdruserfield.c
+++ b/apps/app_setcdruserfield.c
@@ -76,13 +76,7 @@ static int action_setcdruserfield(struct mansession *s, struct message *m)
astman_send_error(s, m, "No UserField specified");
return 0;
}
- c = ast_channel_walk_locked(NULL);
- while (c) {
- if (!strcasecmp(c->name, channel))
- break;
- ast_mutex_unlock(&c->lock);
- c = ast_channel_walk_locked(c);
- }
+ c = ast_get_channel_by_name_locked(channel);
if (!c) {
astman_send_error(s, m, "No such channel");
return 0;
diff --git a/apps/app_softhangup.c b/apps/app_softhangup.c
index 6631b0ad7..124f270c6 100755
--- a/apps/app_softhangup.c
+++ b/apps/app_softhangup.c
@@ -60,6 +60,7 @@ static int softhangup_exec(struct ast_channel *chan, void *data)
while (c) {
strncpy(name, c->name, sizeof(name)-1);
ast_mutex_unlock(&c->lock);
+ /* XXX watch out, i think it is wrong to access c-> after unlocking! */
if (all) {
/* CAPI is set up like CAPI[foo/bar]/clcnt */
if (!strcmp(c->type,"CAPI"))
diff --git a/apps/app_zapscan.c b/apps/app_zapscan.c
index 195fc657c..9b153ed26 100755
--- a/apps/app_zapscan.c
+++ b/apps/app_zapscan.c
@@ -64,15 +64,7 @@ static struct ast_channel *get_zap_channel_locked(int num) {
char name[80];
snprintf(name,sizeof(name),"Zap/%d-1",num);
- c = ast_channel_walk_locked(NULL);
- while(c) {
- if (!strcasecmp(c->name, name)) {
- break;
- }
- ast_mutex_unlock(&c->lock);
- c = ast_channel_walk_locked(c);
- }
- return c;
+ return ast_get_channel_by_name_locked(name);
}
static int careful_write(int fd, unsigned char *data, int len)