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"); }