Module: kamailio
Branch: 4.2
Commit: 32e85b6481b31a1f4aa46603849cb02433e50915
URL: 
https://github.com/kamailio/kamailio/commit/32e85b6481b31a1f4aa46603849cb02433e50915

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2015-01-15T20:15:06+01:00

presence: fix counter and type for removing presentity from cache

- report and patch by Kristian F. Høgh

(cherry picked from commit d43e8965640bbc64e56ef33f27d4f3c3a85c73fa)

---

Modified: modules/presence/event_list.h
Modified: modules/presence/hash.c
Modified: modules/presence/publish.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/32e85b6481b31a1f4aa46603849cb02433e50915.diff
Patch: 
https://github.com/kamailio/kamailio/commit/32e85b6481b31a1f4aa46603849cb02433e50915.patch

---

diff --git a/modules/presence/event_list.h b/modules/presence/event_list.h
index 2ebcafc..29511cb 100644
--- a/modules/presence/event_list.h
+++ b/modules/presence/event_list.h
@@ -83,7 +83,7 @@ struct pres_ev
        event_t* evp;
        str content_type;
        int default_expires;
-       int type;
+       int type; /* category type: WINFO_TIPE, PUBL_TYPE, ...*/
        int etag_not_new;
        /*
         *  0 - the standard mechanism (allocating new etag for each Publish)
diff --git a/modules/presence/hash.c b/modules/presence/hash.c
index 4c6f181..08a3461 100644
--- a/modules/presence/hash.c
+++ b/modules/presence/hash.c
@@ -512,14 +512,16 @@ int insert_phtable(str* pres_uri, int event, char* sphere)
                if(p->sphere== NULL)
                {
                        lock_release(&pres_htable[hash_code].lock);
+                       shm_free(p);
                        ERR_MEM(SHARE_MEM);
                }
                strcpy(p->sphere, sphere);
        }
 
        p->event= event;
-       
+       p->publ_count=1;
 
+       /* link the item in the hash table */
        p->next= pres_htable[hash_code].entries->next;
        pres_htable[hash_code].entries->next= p;
 
diff --git a/modules/presence/publish.c b/modules/presence/publish.c
index 46ec334..4ca9afb 100644
--- a/modules/presence/publish.c
+++ b/modules/presence/publish.c
@@ -134,7 +134,7 @@ void msg_presentity_clean(unsigned int ticks,void *param)
                        event.s = (char *) VAL_STRING(&values[event_col]);
                        event.len = strlen(event.s);
                        pres.event= contains_event(&event, NULL);
-                       if(pres.event== NULL)
+                       if(pres.event==NULL || pres.event->evp==NULL)
                        {
                                LM_ERR("event not found\n");
                                goto error;
@@ -147,7 +147,7 @@ void msg_presentity_clean(unsigned int ticks,void *param)
                        }
                
                        /* delete from hash table */
-                       if(publ_cache_enabled && delete_phtable(&uri, 
pres.event->type)< 0)
+                       if(publ_cache_enabled && delete_phtable(&uri, 
pres.event->evp->type)< 0)
                        {
                                LM_ERR("deleting from pres hash table\n");
                                goto error;


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to