[Asterisk-cvs] asterisk/channels chan_iax2.c, 1.205, 1.206 chan_sip.c, 1.530, 1.531

markster at lists.digium.com markster at lists.digium.com
Tue Oct 12 15:54:21 CDT 2004


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

Modified Files:
	chan_iax2.c chan_sip.c 
Log Message:
Be careful!


Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.205
retrieving revision 1.206
diff -u -d -r1.205 -r1.206
--- chan_iax2.c	10 Oct 2004 20:27:54 -0000	1.205
+++ chan_iax2.c	12 Oct 2004 19:54:54 -0000	1.206
@@ -1983,8 +1983,8 @@
 	return 0;
 }
 
-static struct iax2_peer *build_peer(const char *name, struct ast_variable *v);
-static struct iax2_user *build_user(const char *name, struct ast_variable *v);
+static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, int temponly);
+static struct iax2_user *build_user(const char *name, struct ast_variable *v, int temponly);
 
 static void destroy_user(struct iax2_user *user);
 static void destroy_peer(struct iax2_peer *peer);
@@ -1999,7 +1999,7 @@
 	var = ast_load_realtime("iaxfriends", "name", peername, NULL);
 	if (var) {
 		/* Make sure it's not a user only... */
-		peer = build_peer(peername, var);
+		peer = build_peer(peername, var, 1);
 		if (peer) {
 			/* Add some finishing touches, addresses, etc */
 			peer->temponly = 1;
@@ -2048,7 +2048,7 @@
 	var = ast_load_realtime("iaxfriends", "name", username, NULL);
 	if (var) {
 		/* Make sure it's not a user only... */
-		user = build_user(username, var);
+		user = build_user(username, var, 1);
 		if (user) {
 			/* Add some finishing touches, addresses, etc */
 			user->temponly = 1;
@@ -6366,7 +6366,7 @@
 	return methods;
 }
 
-static struct iax2_peer *build_peer(const char *name, struct ast_variable *v)
+static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, int temponly)
 {
 	struct iax2_peer *peer;
 	struct iax2_peer *prev;
@@ -6376,14 +6376,17 @@
 	int found=0;
 	prev = NULL;
 	ast_mutex_lock(&peerl.lock);
-	peer = peerl.peers;
-	while(peer) {
-		if (!strcasecmp(peer->name, name)) {	
-			break;
+	if (!temponly) {
+		peer = peerl.peers;
+		while(peer) {
+			if (!strcasecmp(peer->name, name)) {	
+				break;
+			}
+			prev = peer;
+			peer = peer->next;
 		}
-		prev = peer;
-		peer = peer->next;
-	}
+	} else
+		peer = NULL;	
 	if (peer) {
 		found++;
 		oldha = peer->ha;
@@ -6538,7 +6541,7 @@
 	return peer;
 }
 
-static struct iax2_user *build_user(const char *name, struct ast_variable *v)
+static struct iax2_user *build_user(const char *name, struct ast_variable *v, int temponly)
 {
 	struct iax2_user *prev, *user;
 	struct iax2_context *con, *conl = NULL;
@@ -6549,14 +6552,17 @@
 	
 	prev = NULL;
 	ast_mutex_lock(&userl.lock);
-	user = userl.users;
-	while(user) {
-		if (!strcasecmp(user->name, name)) {	
-			break;
+	if (!temponly) {
+		user = userl.users;
+		while(user) {
+			if (!strcasecmp(user->name, name)) {	
+				break;
+			}
+			prev = user;
+			user = user->next;
 		}
-		prev = user;
-		user = user->next;
-	}
+	} else
+		user = NULL;
 	if (user) {
 		found++;
 		oldha = user->ha;
@@ -6933,7 +6939,7 @@
 			utype = ast_variable_retrieve(cfg, cat, "type");
 			if (utype) {
 				if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
-					user = build_user(cat, ast_variable_browse(cfg, cat));
+					user = build_user(cat, ast_variable_browse(cfg, cat), 0);
 					if (user) {
 						ast_mutex_lock(&userl.lock);
 						user->next = userl.users;
@@ -6942,7 +6948,7 @@
 					}
 				}
 				if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
-					peer = build_peer(cat, ast_variable_browse(cfg, cat));
+					peer = build_peer(cat, ast_variable_browse(cfg, cat), 0);
 					if (peer) {
 						ast_mutex_lock(&peerl.lock);
 						peer->next = peerl.peers;

Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.530
retrieving revision 1.531
diff -u -d -r1.530 -r1.531
--- chan_sip.c	10 Oct 2004 17:32:55 -0000	1.530
+++ chan_sip.c	12 Oct 2004 19:54:54 -0000	1.531
@@ -1042,7 +1042,7 @@
 		realtime_update_peer(p->name, &p->addr, p->username, expiry);
 }
 
-static struct sip_peer *build_peer(const char *name, struct ast_variable *v);
+static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int temponly);
 
 static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *sin)
 {
@@ -1060,7 +1060,7 @@
 		var = ast_load_realtime("sipfriends", "ipaddr", iabuf, NULL);
 	if (var) {
 		/* Make sure it's not a user only... */
-		peer = build_peer(peername, var);
+		peer = build_peer(peername, var, 1);
 		if (peer) {
 			/* Add some finishing touches, addresses, etc */
 			peer->temponly = 1;
@@ -8147,7 +8147,7 @@
 }
 
 /*--- build_peer: Build peer from config file ---*/
-static struct sip_peer *build_peer(const char *name, struct ast_variable *v)
+static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int temponly)
 {
 	struct sip_peer *peer;
 	struct sip_peer *prev;
@@ -8157,13 +8157,17 @@
 	int found=0;
 	prev = NULL;
 	ast_mutex_lock(&peerl.lock);
-	peer = peerl.peers;
-	while(peer) {
-		if (!strcasecmp(peer->name, name)) {	
-			break;
+	if (temponly) {
+		peer = NULL;
+	} else {
+		peer = peerl.peers;
+		while(peer) {
+			if (!strcasecmp(peer->name, name)) {	
+				break;
+			}
+			prev = peer;
+			peer = peer->next;
 		}
-		prev = peer;
-		peer = peer->next;
 	}
 	if (peer) {
 		found++;
@@ -8598,7 +8602,7 @@
 					}
 				}
 				if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
-					peer = build_peer(cat, ast_variable_browse(cfg, cat));
+					peer = build_peer(cat, ast_variable_browse(cfg, cat), 0);
 					if (peer) {
 						ast_mutex_lock(&peerl.lock);
 						peer->next = peerl.peers;




More information about the svn-commits mailing list