Module: sip-router
Branch: master
Commit: 27eba09b603b265ce4213d238c132249189ae6e8
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=27eba09…
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
---
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");