Browse code

pua_reginfo: use ruid to fix comparation of contact

(ptr == c) is always false. Using ruid instead.

Victor Seva authored on 15/07/2015 14:00:03
Showing 1 changed files
... ...
@@ -101,10 +101,14 @@ str* build_reginfo_full(urecord_t * record, str uri, ucontact_t* c, int type) {
101 101
 	snprintf(buf, sizeof(buf), "%p", record);
102 102
 	xmlNewProp(registration_node, BAD_CAST "id", BAD_CAST buf);
103 103
 
104
+	LM_DBG("Updated Contact %.*s[%.*s]\n", c->c.len, c->c.s,
105
+		c->ruid.len, c->ruid.s);
106
+
104 107
 	ptr = record->contacts;
105 108
 	while (ptr) {
106 109
 		if (VALID_CONTACT(ptr, cur_time)) {
107
-			LM_DBG("Contact %.*s, %p\n", ptr->c.len, ptr->c.s, ptr);
110
+			LM_DBG("Contact %.*s[%.*s]\n", ptr->c.len, ptr->c.s,
111
+				ptr->ruid.len, ptr->ruid.s);
108 112
 			/* Contact-Node */
109 113
 			contact_node =xmlNewChild(registration_node, NULL, BAD_CAST "contact", NULL) ;
110 114
 			if( contact_node ==NULL) {
... ...
@@ -115,7 +119,9 @@ str* build_reginfo_full(urecord_t * record, str uri, ucontact_t* c, int type) {
115 119
 			snprintf(buf, sizeof(buf), "%p", ptr);
116 120
 			xmlNewProp(contact_node, BAD_CAST "id", BAD_CAST buf);
117 121
 			/* Check, if this is the modified contact: */
118
-			if (ptr == c) {
122
+			if ((c->ruid.len == ptr->ruid.len) &&
123
+				!memcmp(c->ruid.s, ptr->ruid.s, c->ruid.len))
124
+			{
119 125
 				if ((type & UL_CONTACT_INSERT) || (type & UL_CONTACT_UPDATE)) {
120 126
 					reg_active = 1;
121 127
 					xmlNewProp(contact_node, BAD_CAST "state", BAD_CAST "active");