presence: define modes for publ_cache parameter
authorDaniel-Constantin Mierla <miconda@gmail.com>
Sun, 19 Apr 2020 07:02:09 +0000 (09:02 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 20 Apr 2020 07:12:24 +0000 (09:12 +0200)
src/modules/presence/notify.c
src/modules/presence/presence.c
src/modules/presence/presence.h
src/modules/presence/presentity.c
src/modules/presence/publish.c

index 92c5b60..702d07d 100644 (file)
@@ -609,7 +609,7 @@ str *get_p_notify_body(str pres_uri, pres_ev_t *event, str *etag, str *contact)
        }
 
        /* if in db_only mode, get the presentity information from database - skip htable search */
-       if(publ_cache_enabled) {
+       if(publ_cache_mode == PS_PCACHE_HYBRID) {
                /* search in hash table if any record exists */
                hash_code = core_case_hash(&pres_uri, NULL, phtable_size);
                if(search_phtable(&pres_uri, event->evp->type, hash_code) == NULL) {
index 3cbdab9..779a601 100644 (file)
@@ -155,7 +155,7 @@ int pres_subs_dbmode = WRITE_BACK;
 int pres_sphere_enable = 0;
 int pres_timeout_rm_subs = 1;
 int pres_send_fast_notify = 1;
-int publ_cache_enabled = 1;
+int publ_cache_mode = PS_PCACHE_HYBRID;
 int pres_waitn_time = 5;
 int pres_notifier_poll_rate = 10;
 int pres_notifier_processes = 1;
@@ -225,7 +225,7 @@ static param_export_t params[]={
        { "subs_htable_size",       INT_PARAM, &shtable_size},
        { "pres_htable_size",       INT_PARAM, &phtable_size},
        { "subs_db_mode",           INT_PARAM, &pres_subs_dbmode},
-       { "publ_cache",             INT_PARAM, &publ_cache_enabled},
+       { "publ_cache",             INT_PARAM, &publ_cache_mode},
        { "enable_sphere_check",    INT_PARAM, &pres_sphere_enable},
        { "timeout_rm_subs",        INT_PARAM, &pres_timeout_rm_subs},
        { "send_fast_notify",       INT_PARAM, &pres_send_fast_notify},
@@ -406,7 +406,7 @@ static int mod_init(void)
                }
        }
 
-       if(publ_cache_enabled) {
+       if(publ_cache_mode==PS_PCACHE_HYBRID) {
                if(phtable_size < 1)
                        phtable_size = 256;
                else
index 1e54496..f571389 100644 (file)
 #define NO_UPDATE_TYPE -1
 #define UPDATED_TYPE 1
 
+#define PS_PCACHE_NONE 0
+#define PS_PCACHE_HYBRID 1
+#define PS_PCACHE_RECORD 1
+
 /** TM bind */
 extern struct tm_binds tmb;
 
@@ -77,7 +81,7 @@ extern uint32_t pres_min_expires;
 extern int pres_min_expires_action;
 extern uint32_t pres_max_expires;
 extern int pres_subs_dbmode;
-extern int publ_cache_enabled;
+extern int publ_cache_mode;
 extern int pres_sphere_enable;
 extern int pres_timeout_rm_subs;
 extern int pres_send_fast_notify;
index 7e742f5..b7f3d49 100644 (file)
@@ -638,7 +638,7 @@ int update_presentity(struct sip_msg *msg, presentity_t *presentity, str *body,
 
                /* insert new record in hash_table */
 
-               if(publ_cache_enabled
+               if(publ_cache_mode==PS_PCACHE_HYBRID
                                && insert_phtable(
                                                   &pres_uri, presentity->event->evp->type, sphere)
                                                   < 0) {
@@ -980,7 +980,7 @@ int update_presentity(struct sip_msg *msg, presentity_t *presentity, str *body,
                        }
 
                        /* delete from hash table */
-                       if(publ_cache_enabled
+                       if(publ_cache_mode == PS_PCACHE_HYBRID
                                        && delete_phtable(&pres_uri, presentity->event->evp->type)
                                                           < 0) {
                                LM_ERR("deleting record from hash table\n");
@@ -1102,7 +1102,7 @@ int update_presentity(struct sip_msg *msg, presentity_t *presentity, str *body,
                        /* updated stored sphere */
                        if(pres_sphere_enable
                                        && presentity->event->evp->type == EVENT_PRESENCE) {
-                               if(publ_cache_enabled
+                               if(publ_cache_mode == PS_PCACHE_HYBRID
                                                && update_phtable(presentity, &pres_uri, body) < 0) {
                                        LM_ERR("failed to update sphere for presentity\n");
                                        goto error;
@@ -1488,7 +1488,7 @@ char *get_sphere(str *pres_uri)
                return NULL;
        }
 
-       if(publ_cache_enabled) {
+       if(publ_cache_mode == PS_PCACHE_HYBRID) {
                /* search in hash table*/
                hash_code = core_case_hash(pres_uri, NULL, phtable_size);
 
index 41c0486..6cfbfd9 100644 (file)
@@ -140,7 +140,7 @@ void msg_presentity_clean(unsigned int ticks, void *param)
                        }
 
                        /* delete from hash table */
-                       if(publ_cache_enabled
+                       if(publ_cache_mode==PS_PCACHE_HYBRID
                                        && delete_phtable(&uri, pres.event->evp->type) < 0) {
                                LM_ERR("deleting from presentity hash table\n");
                                goto error;