Module: sip-router Branch: master Commit: 74d73953327ad7702922b27ba37c71e3283659c3 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=74d73953...
Author: Richard Good richard.good@smilecoms.com Committer: Richard Good richard.good@smilecoms.com Date: Wed Jan 29 09:00:37 2014 +0200
modules/presence: Changed delete_shtable function to check dialog's full tag set Changed delete_shtable to take subs_t pointer as parameter to compare dialog's full tag set before deleting This changes presence API and delete_shtable is exported function - only effected module is rls
---
modules/presence/hash.c | 10 +++++++--- modules/presence/hash.h | 4 ++-- modules/presence/subscribe.c | 10 +++++++++- 3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/modules/presence/hash.c b/modules/presence/hash.c index de7f08f..026fe1b 100644 --- a/modules/presence/hash.c +++ b/modules/presence/hash.c @@ -275,7 +275,7 @@ int insert_shtable(shtable_t htable,unsigned int hash_code, subs_t* subs) return 0; }
-int delete_shtable(shtable_t htable,unsigned int hash_code,str to_tag) +int delete_shtable(shtable_t htable,unsigned int hash_code,subs_t* subs) { subs_t* s= NULL, *ps= NULL; int found= -1; @@ -287,8 +287,12 @@ int delete_shtable(shtable_t htable,unsigned int hash_code,str to_tag) while(s) { - if(s->to_tag.len== to_tag.len && - strncmp(s->to_tag.s, to_tag.s, to_tag.len)== 0) + if(s->callid.len==subs->callid.len && + strncmp(s->callid.s, subs->callid.s, subs->callid.len)==0 && + s->to_tag.len== subs->to_tag.len && + strncmp(s->to_tag.s, subs->to_tag.s, subs->to_tag.len)==0 && + s->from_tag.len== subs->from_tag.len && + strncmp(s->from_tag.s, subs->from_tag.s, subs->from_tag.len)== 0) { found= s->local_cseq +1; ps->next= s->next; diff --git a/modules/presence/hash.h b/modules/presence/hash.h index 7c7010d..4bcbefb 100644 --- a/modules/presence/hash.h +++ b/modules/presence/hash.h @@ -78,7 +78,7 @@ struct subscription* search_shtable(shtable_t htable, str callid,str to_tag,str
int insert_shtable(shtable_t htable, unsigned int hash_code, struct subscription* subs);
-int delete_shtable(shtable_t htable, unsigned int hash_code, str to_tag); +int delete_shtable(shtable_t htable, unsigned int hash_code, struct subscription* subs);
int update_shtable(shtable_t htable, unsigned int hash_code, struct subscription* subs, int type); @@ -99,7 +99,7 @@ typedef int (*insert_shtable_t)(shtable_t htable, unsigned int hash_code, struct subscription* subs);
typedef int (*delete_shtable_t)(shtable_t htable, unsigned int hash_code, - str to_tag); + struct subscription* subs);
typedef int (*update_shtable_t)(shtable_t htable, unsigned int hash_code, struct subscription* subs, int type); diff --git a/modules/presence/subscribe.c b/modules/presence/subscribe.c index aff55f3..0a18eff 100644 --- a/modules/presence/subscribe.c +++ b/modules/presence/subscribe.c @@ -456,11 +456,19 @@ int update_subs_db(subs_t* subs, int type) void delete_subs(str* pres_uri, str* ev_name, str* to_tag, str* from_tag, str* callid) { + subs_t subs; + memset(&subs, 0, sizeof(subs_t)); + + subs.pres_uri = *pres_uri; + subs.from_tag = *from_tag; + subs.to_tag = *to_tag; + subs.callid = *callid; + /* delete record from hash table also if not in dbonly mode */ if(subs_dbmode != DB_ONLY) { unsigned int hash_code= core_hash(pres_uri, ev_name, shtable_size); - if(delete_shtable(subs_htable, hash_code, *to_tag) < 0) + if(delete_shtable(subs_htable, hash_code, &subs) < 0) LM_ERR("Failed to delete subscription from memory\n"); }