Module: kamailio Branch: master Commit: 85029d414384912879b45a34bdeb8f1372cc3780 URL: https://github.com/kamailio/kamailio/commit/85029d414384912879b45a34bdeb8f13...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2015-01-03T12:21:04+01:00
presence: configurable matching criteria to remove subscriptions from memory
- adjusted the commit 74d73953327ad7702922b27ba37c71e3283659c3, being reported that subscriptions are not found (Jan Gaida)
---
Modified: modules/presence/hash.c Modified: modules/presence/presence.c
---
Diff: https://github.com/kamailio/kamailio/commit/85029d414384912879b45a34bdeb8f13... Patch: https://github.com/kamailio/kamailio/commit/85029d414384912879b45a34bdeb8f13...
---
diff --git a/modules/presence/hash.c b/modules/presence/hash.c index 4c6f181..6e85d37 100644 --- a/modules/presence/hash.c +++ b/modules/presence/hash.c @@ -42,6 +42,13 @@ #include "hash.h" #include "notify.h"
+/* matching mode when removing subscriptions from memory */ +extern int pres_subs_remove_match; + +/** + * create the subscription hash table in shared memory + * - hash_size: number of slots + */ shtable_t new_shtable(int hash_size) { shtable_t htable= NULL; @@ -287,12 +294,26 @@ int delete_shtable(shtable_t htable,unsigned int hash_code,subs_t* subs) while(s) { - if(s->callid.len==subs->callid.len + if(pres_subs_remove_match==0) { + /* match on to-tag only (unique, local generated - faster) */ + if(s->to_tag.len==subs->to_tag.len + && strncmp(s->to_tag.s,subs->to_tag.s,subs->to_tag.len)==0) + { + found = 0; + } + } else { + /* match on all dialog attributes (distributed systems) */ + if(s->callid.len==subs->callid.len && s->to_tag.len==subs->to_tag.len && s->from_tag.len==subs->from_tag.len && strncmp(s->callid.s,subs->callid.s,subs->callid.len)==0 && strncmp(s->to_tag.s,subs->to_tag.s,subs->to_tag.len)==0 && strncmp(s->from_tag.s,subs->from_tag.s,subs->from_tag.len)==0) + { + found = 0; + } + } + if(found==0) { found= s->local_cseq +1; ps->next= s->next; diff --git a/modules/presence/presence.c b/modules/presence/presence.c index 03eeb56..5175665 100644 --- a/modules/presence/presence.c +++ b/modules/presence/presence.c @@ -98,6 +98,7 @@ int pres_fetch_rows = 500; int library_mode= 0; str server_address= {0, 0}; evlist_t* EvList= NULL; +int pres_subs_remove_match = 0;
/* to tag prefix */ char* to_tag_pref = "10"; @@ -205,6 +206,7 @@ static param_export_t params[]={ { "fetch_rows", INT_PARAM, &pres_fetch_rows}, { "db_table_lock_type", INT_PARAM, &db_table_lock_type}, { "local_log_level", PARAM_INT, &pres_local_log_level}, + { "subs_remove_match", PARAM_INT, &pres_subs_remove_match}, {0,0,0} };