[svn-commits] trunk r31895 - /trunk/channels/chan_sip.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sat Jun 3 17:09:14 MST 2006


Author: rizzo
Date: Sat Jun  3 19:09:13 2006
New Revision: 31895

URL: http://svn.digium.com/view/asterisk?rev=31895&view=rev
Log:
add a bit of comment on what build_route does,
plus minor code simplification.

Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=31895&r1=31894&r2=31895&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sat Jun  3 19:09:13 2006
@@ -6622,7 +6622,11 @@
 	
 	p->route_persistant = backwards;
 	
-	/* We build up head, then assign it to p->route when we're done */
+	/* Build a tailq, then assign it to p->route when done.
+	 * If backwards, we add entries from the head so they end up
+	 * in reverse order. However, we do need to maintain a correct
+	 * tail pointer because the contact is always at the end.
+	 */
 	head = NULL;
 	tail = head;
 	/* 1st we pass through all the hops in any Record-Route headers */
@@ -6631,12 +6635,7 @@
 		rr = __get_header(req, "Record-Route", &start);
 		if (*rr == '\0')
 			break;
-		for (;;) {
-			/* Each route entry */
-			/* Find < */
-			rr = strchr(rr, '<');
-			if (!rr) 
-				break; /* No more hops */
+		for (; (rr = strchr(rr, '<')) ; rr += len) { /* Each route entry */
 			++rr;
 			len = strcspn(rr, ">") + 1;
 			/* Make a struct route */
@@ -6650,7 +6649,8 @@
 					thishop->next = head;
 					head = thishop;
 					/* If this was the first then it'll be the tail */
-					if (!tail) tail = thishop;
+					if (!tail)
+						tail = thishop;
 				} else {
 					thishop->next = NULL;
 					/* Link in at the end */
@@ -6661,7 +6661,6 @@
 					tail = thishop;
 				}
 			}
-			rr += len;
 		}
 	}
 



More information about the svn-commits mailing list