[asterisk-commits] tilghman: branch 1.6.0 r118253 - in /branches/1.6.0: ./ channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun May 25 11:20:32 CDT 2008


Author: tilghman
Date: Sun May 25 11:20:32 2008
New Revision: 118253

URL: http://svn.digium.com/view/asterisk?view=rev&rev=118253
Log:
Merged revisions 118252 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r118252 | tilghman | 2008-05-25 11:17:05 -0500 (Sun, 25 May 2008) | 20 lines

Merged revisions 118251 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r118251 | tilghman | 2008-05-25 11:02:04 -0500 (Sun, 25 May 2008) | 12 lines

Realtime flag affects construction in multiple ways, so consulting whether
rtcachefriends was set was done too soon (needed to be done inside build_peer,
not just as a flag to build_peer).
Also, fullcontact needed to be reconstructed, because realtime separates the
embedded ';' into multiple fields.
(closes issue #12722)
 Reported by: barthpbx
 Patches: 
       20080525__bug12722.diff.txt uploaded by Corydon76 (license 14)
 Tested by: barthpbx
 (Much of the discussion happened on #asterisk-dev for diagnosing this issue)

........

................

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/channels/chan_sip.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/chan_sip.c?view=diff&rev=118253&r1=118252&r2=118253
==============================================================================
--- branches/1.6.0/channels/chan_sip.c (original)
+++ branches/1.6.0/channels/chan_sip.c Sun May 25 11:20:32 2008
@@ -3693,7 +3693,7 @@
 
 
 	/* Peer found in realtime, now build it in memory */
-	peer = build_peer(newpeername, var, varregs, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
+	peer = build_peer(newpeername, var, varregs, 1);
 	if (!peer) {
 		if(peerlist)
 			ast_config_destroy(peerlist);
@@ -19728,14 +19728,16 @@
 	char callback[256] = "";
 	const char *srvlookup = NULL;
 	static int deprecation_warning = 1;
-
-	if (!realtime)
+	struct ast_str *fullcontact = ast_str_alloca(sizeof(peer->fullcontact));
+
+	if (!realtime || ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
 		/* Note we do NOT use find_peer here, to avoid realtime recursion */
 		/* We also use a case-sensitive comparison (unlike find_peer) so
 		   that case changes made to the peer name will be properly handled
 		   during reload
 		*/
 		peer = ASTOBJ_CONTAINER_FIND_UNLINK_FULL(&peerl, name, name, 0, 0, strcmp);
+	}
 
 	if (peer) {
 		/* Already in the list, remove it and it will be added back (or FREE'd)  */
@@ -19746,7 +19748,7 @@
 		if (!(peer = ast_calloc(1, sizeof(*peer))))
 			return NULL;
 
-		if (realtime) {
+		if (realtime && !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
 			rpeerobjs++;
 			ast_debug(3, "-REALTIME- peer built. Name: %s. Peer objects: %d\n", name, rpeerobjs);
 		} else
@@ -19791,8 +19793,12 @@
 		} else if (realtime && !strcasecmp(v->name, "name"))
 			ast_copy_string(peer->name, v->value, sizeof(peer->name));
 		else if (realtime && !strcasecmp(v->name, "fullcontact")) {
-			ast_copy_string(peer->fullcontact, v->value, sizeof(peer->fullcontact));
-			peer->rt_fromcontact = TRUE;
+			/* Reconstruct field, because realtime separates our value at the ';' */
+			if (fullcontact->used > 0) {
+				ast_str_append(&fullcontact, 0, ";%s", v->value);
+			} else {
+				ast_str_set(&fullcontact, 0, "%s", v->value);
+			}
 		} else if (!strcasecmp(v->name, "secret")) 
 			ast_copy_string(peer->secret, v->value, sizeof(peer->secret));
 		else if (!strcasecmp(v->name, "md5secret")) 
@@ -20013,6 +20019,11 @@
 		}
 	}
 
+	if (fullcontact->used > 0) {
+		ast_copy_string(peer->fullcontact, fullcontact->str, sizeof(peer->fullcontact));
+		peer->rt_fromcontact = TRUE;
+	}
+
 	if (srvlookup) {
 		if (ast_get_ip_or_srv(&peer->addr, srvlookup, 
 								global_srvlookup ?  




More information about the asterisk-commits mailing list