Browse code

presence: configurable matching criteria to remove subscriptions from memory

- adjusted the commit 74d73953327ad7702922b27ba37c71e3283659c3, being
reported that subscriptions are not found (Jan Gaida)

Daniel-Constantin Mierla authored on 03/01/2015 10:44:38
Showing 2 changed files
... ...
@@ -42,6 +42,13 @@
42 42
 #include "hash.h"
43 43
 #include "notify.h"
44 44
 
45
+/* matching mode when removing subscriptions from memory */
46
+extern int pres_subs_remove_match;
47
+
48
+/**
49
+ * create the subscription hash table in shared memory
50
+ * - hash_size: number of slots
51
+ */
45 52
 shtable_t new_shtable(int hash_size)
46 53
 {
47 54
 	shtable_t htable= NULL;
... ...
@@ -287,12 +294,26 @@ int delete_shtable(shtable_t htable,unsigned int hash_code,subs_t* subs)
287 294
 		
288 295
 	while(s)
289 296
 	{
290
-		if(s->callid.len==subs->callid.len
297
+		if(pres_subs_remove_match==0) {
298
+			/* match on to-tag only (unique, local generated - faster) */
299
+			if(s->to_tag.len==subs->to_tag.len
300
+				&& strncmp(s->to_tag.s,subs->to_tag.s,subs->to_tag.len)==0)
301
+			{
302
+				found = 0;
303
+			}
304
+		} else {
305
+			/* match on all dialog attributes (distributed systems) */
306
+			if(s->callid.len==subs->callid.len
291 307
 				&& s->to_tag.len==subs->to_tag.len
292 308
 				&& s->from_tag.len==subs->from_tag.len
293 309
 				&& strncmp(s->callid.s,subs->callid.s,subs->callid.len)==0
294 310
 				&& strncmp(s->to_tag.s,subs->to_tag.s,subs->to_tag.len)==0
295 311
 				&& strncmp(s->from_tag.s,subs->from_tag.s,subs->from_tag.len)==0)
312
+			{
313
+				found = 0;
314
+			}
315
+		}
316
+		if(found==0)
296 317
 		{
297 318
 			found= s->local_cseq +1;
298 319
 			ps->next= s->next;
... ...
@@ -98,6 +98,7 @@ int pres_fetch_rows = 500;
98 98
 int library_mode= 0;
99 99
 str server_address= {0, 0};
100 100
 evlist_t* EvList= NULL;
101
+int pres_subs_remove_match = 0;
101 102
 
102 103
 /* to tag prefix */
103 104
 char* to_tag_pref = "10";
... ...
@@ -205,6 +206,7 @@ static param_export_t params[]={
205 206
 	{ "fetch_rows",             INT_PARAM, &pres_fetch_rows},
206 207
 	{ "db_table_lock_type",     INT_PARAM, &db_table_lock_type},
207 208
 	{ "local_log_level",        PARAM_INT, &pres_local_log_level},
209
+	{ "subs_remove_match",      PARAM_INT, &pres_subs_remove_match},
208 210
     {0,0,0}
209 211
 };
210 212