From d43e8965640bbc64e56ef33f27d4f3c3a85c73fa Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Thu, 15 Jan 2015 17:54:18 +0100 Subject: [PATCH] presence: fix counter and type for removing presentity from cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - report and patch by Kristian F. Høgh --- modules/presence/event_list.h | 2 +- modules/presence/hash.c | 4 +++- modules/presence/publish.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/presence/event_list.h b/modules/presence/event_list.h index 2ebcafc5943..29511cbc89b 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 6e85d370b9e..11d9e3e3182 100644 --- a/modules/presence/hash.c +++ b/modules/presence/hash.c @@ -533,14 +533,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 46ec334d777..4ca9afba1fa 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;