[Asterisk-cvs] asterisk/apps app_groupcount.c, 1.15, 1.16 app_setcdruserfield.c, 1.6, 1.7 app_softhangup.c, 1.6, 1.7 app_zapscan.c, 1.16, 1.17

kpfleming at lists.digium.com kpfleming at lists.digium.com
Sun Jun 5 22:26:47 CDT 2005


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv4861/apps

Modified Files:
	app_groupcount.c app_setcdruserfield.c app_softhangup.c 
	app_zapscan.c 
Log Message:
more efficient (and understandable) ast_channel_walk_locked, and vastly more efficient ast_channel_by_name_locked (bug #4265)


Index: app_groupcount.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_groupcount.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- app_groupcount.c	15 May 2005 23:32:38 -0000	1.15
+++ app_groupcount.c	6 Jun 2005 02:29:18 -0000	1.16
@@ -174,9 +174,8 @@
 		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 @@
 		}
 		numchans++;
 		ast_mutex_unlock(&c->lock);
-		c = ast_channel_walk_locked(c);
 	}
 
 	if (havepattern)

Index: app_setcdruserfield.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_setcdruserfield.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- app_setcdruserfield.c	21 Apr 2005 06:02:43 -0000	1.6
+++ app_setcdruserfield.c	6 Jun 2005 02:29:18 -0000	1.7
@@ -76,13 +76,7 @@
 		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;

Index: app_softhangup.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_softhangup.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- app_softhangup.c	21 Apr 2005 06:02:43 -0000	1.6
+++ app_softhangup.c	6 Jun 2005 02:29:18 -0000	1.7
@@ -60,6 +60,7 @@
 	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")) 

Index: app_zapscan.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_zapscan.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- app_zapscan.c	21 Apr 2005 06:02:43 -0000	1.16
+++ app_zapscan.c	6 Jun 2005 02:29:18 -0000	1.17
@@ -64,15 +64,7 @@
 	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)




More information about the svn-commits mailing list