Module: sip-router
Branch: 4.1
Commit: 18afdc79aeb2b46c6eda4b66e40efae49d524701
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=18afdc7…
Author: Hugh Waite <hugh.waite(a)crocodile-rcs.com>
Committer: Hugh Waite <hugh.waite(a)crocodile-rcs.com>
Date: Fri Nov 22 09:28:38 2013 +0000
modules/registrar: Invalidate temporary GRUUs when the Call-ID changes for a sip.instance
- Fixes FS#368
(cherry picked from commit 27eba09b603b265ce4213d238c132249189ae6e8)
---
modules/registrar/save.c | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/modules/registrar/save.c b/modules/registrar/save.c
index bc816cd..fc5d564 100644
--- a/modules/registrar/save.c
+++ b/modules/registrar/save.c
@@ -716,10 +716,10 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,
int _mode,
ptr=_r->contacts;
while(ptr)
{
- ptr0 = ptr;
+ ptr0 = ptr->next;
if(ptr!=c)
ul.delete_ucontact(_r, ptr);
- ptr=ptr0->next;
+ ptr=ptr0;
}
updated=1;
}
@@ -746,13 +746,32 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,
int _mode,
ptr=_r->contacts;
while(ptr)
{
- ptr0 = ptr;
+ ptr0 = ptr->next;
if(ptr!=c)
ul.delete_ucontact(_r, ptr);
- ptr=ptr0->next;
+ ptr=ptr0;
}
updated=1;
}
+ /* If call-id has changed then delete all records with this sip.instance
+ then insert new record */
+ if (ci->instance.s != NULL &&
+ (ci->callid->len != c->callid.len ||
+ strncmp(ci->callid->s, c->callid.s, ci->callid->len) != 0))
+ {
+ ptr = _r->contacts;
+ while (ptr)
+ {
+ ptr0 = ptr->next;
+ if ((ptr != c) && ptr->instance.len == c->instance.len &&
+ strncmp(ptr->instance.s, c->instance.s, ptr->instance.len) == 0)
+ {
+ ul.delete_ucontact(_r, ptr);
+ }
+ ptr = ptr0;
+ }
+ updated = 1;
+ }
if (ul.update_ucontact(_r, c, ci) < 0) {
rerrno = R_UL_UPD_C;
LM_ERR("failed to update contact\n");