Browse Source

presence: fix counter and type for removing presentity from cache

- report and patch by Kristian F. Høgh
Daniel-Constantin Mierla 10 years ago
parent
commit
d43e896564
3 changed files with 6 additions and 4 deletions
  1. 1 1
      modules/presence/event_list.h
  2. 3 1
      modules/presence/hash.c
  3. 2 2
      modules/presence/publish.c

+ 1 - 1
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)

+ 3 - 1
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;
 

+ 2 - 2
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;