Parcourir la source

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

Richard Good il y a 11 ans
Parent
commit
74d7395332
3 fichiers modifiés avec 18 ajouts et 6 suppressions
  1. 7 3
      modules/presence/hash.c
  2. 2 2
      modules/presence/hash.h
  3. 9 1
      modules/presence/subscribe.c

+ 7 - 3
modules/presence/hash.c

@@ -275,7 +275,7 @@ int insert_shtable(shtable_t htable,unsigned int hash_code, subs_t* subs)
 	return 0;
 	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;
 	subs_t* s= NULL, *ps= NULL;
 	int found= -1;
 	int found= -1;
@@ -287,8 +287,12 @@ int delete_shtable(shtable_t htable,unsigned int hash_code,str to_tag)
 		
 		
 	while(s)
 	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;
 			found= s->local_cseq +1;
 			ps->next= s->next;
 			ps->next= s->next;

+ 2 - 2
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 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 update_shtable(shtable_t htable, unsigned int hash_code, struct subscription* subs,
 		int type);
 		int type);
@@ -99,7 +99,7 @@ typedef int (*insert_shtable_t)(shtable_t htable, unsigned int hash_code,
 		struct subscription* subs);
 		struct subscription* subs);
 
 
 typedef int (*delete_shtable_t)(shtable_t htable, unsigned int hash_code,
 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,
 typedef int (*update_shtable_t)(shtable_t htable, unsigned int hash_code,
 		struct subscription* subs, int type);
 		struct subscription* subs, int type);

+ 9 - 1
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,
 void delete_subs(str* pres_uri, str* ev_name, str* to_tag,
 		str* from_tag, str* callid)
 		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 */
 	/* delete record from hash table also if not in dbonly mode */
 	if(subs_dbmode != DB_ONLY)
 	if(subs_dbmode != DB_ONLY)
 	{
 	{
 		unsigned int hash_code= core_hash(pres_uri, ev_name, shtable_size);
 		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");
 			LM_ERR("Failed to delete subscription from memory\n");
 	}
 	}