return ret;
}
-/* in-memory presentity records */
+/**
+ * ==============================
+ * in-memory presentity records
+ * ==============================
+ */
static ps_ptable_t *_ps_ptable = NULL;
*/
ps_presentity_t *ps_presentity_new(ps_presentity_t *pt, int mtype)
{
- int bsize = 0;
+ uint32_t bsize = 0;
ps_presentity_t *ptn = NULL;
char *p = NULL;
{
ps_presentity_t ptc;
ps_presentity_t *ptn = NULL;
- int idx = 0;
+ uint32_t idx = 0;
/* copy struct to fill in missing fields */
memcpy(&ptc, pt, sizeof(ps_presentity_t));
return -1;
}
- idx = ptn->hashid % _ps_ptable->ssize;
+ idx = ptn->hashid & (_ps_ptable->ssize - 1);
lock_get(&_ps_ptable->slots[idx].lock);
if(_ps_ptable->slots[idx].plist == NULL) {
{
ps_presentity_t ptc;
ps_presentity_t *ptn = NULL;
- int idx = 0;
+ uint32_t idx = 0;
/* copy struct to fill in missing fields */
memcpy(&ptc, pt, sizeof(ps_presentity_t));
ptc.ruid = pres_sruid.uid;
}
- idx = ptc.hashid % _ps_ptable->ssize;
+ idx = ptc.hashid & (_ps_ptable->ssize - 1);
lock_get(&_ps_ptable->slots[idx].lock);
ptn = _ps_ptable->slots[idx].plist;
ptn = ptn->next;
}
+ if(ptn!=NULL) {
+ ps_presentity_free(ptn, 0);
+ }
+
ptn = ps_presentity_new(&ptc, 0);
if(ptn==NULL) {
lock_release(&_ps_ptable->slots[idx].lock);
{
ps_presentity_t ptc;
ps_presentity_t *ptn = NULL;
- int idx = 0;
+ uint32_t idx = 0;
/* copy struct to fill in missing fields */
memcpy(&ptc, pt, sizeof(ps_presentity_t));
ptc.ruid = pres_sruid.uid;
}
- idx = ptc.hashid % _ps_ptable->ssize;
+ idx = ptc.hashid & (_ps_ptable->ssize - 1);
lock_get(&_ps_ptable->slots[idx].lock);
ptn = _ps_ptable->slots[idx].plist;
{
ps_presentity_t ptc;
ps_presentity_t *ptn = NULL;
- int idx = 0;
+ uint32_t idx = 0;
/* copy struct to fill in missing fields */
memcpy(&ptc, pt, sizeof(ps_presentity_t));
ptc.hashid = core_case_hash(&pt->user, &pt->domain, 0);
- idx = ptc.hashid % _ps_ptable->ssize;
+ idx = ptc.hashid & (_ps_ptable->ssize - 1);
lock_get(&_ps_ptable->slots[idx].lock);
ptn = _ps_ptable->slots[idx].plist;
ps_presentity_t *ptl = NULL;
ps_presentity_t *ptd = NULL;
ps_presentity_t *pte = NULL;
- int idx = 0;
+ uint32_t idx = 0;
memset(&ptc, 0, sizeof(ps_presentity_t));
ptc.user = *user;
ptc.domain = *domain;
ptc.hashid = core_case_hash(&ptc.user, &ptc.domain, 0);
- idx = ptc.hashid % _ps_ptable->ssize;
+ idx = ptc.hashid & (_ps_ptable->ssize - 1);
lock_get(&_ps_ptable->slots[idx].lock);
ptn = _ps_ptable->slots[idx].plist;
ps_presentity_t ptc;
ps_presentity_t *ptn = NULL;
ps_presentity_t *ptd = NULL;
- int idx = 0;
+ uint32_t idx = 0;
memset(&ptc, 0, sizeof(ps_presentity_t));
ptc.event = *event;
ptc.etag = *etag;
ptc.hashid = core_case_hash(&ptc.user, &ptc.domain, 0);
- idx = ptc.hashid % _ps_ptable->ssize;
+ idx = ptc.hashid & (_ps_ptable->ssize - 1);
lock_get(&_ps_ptable->slots[idx].lock);
ptn = _ps_ptable->slots[idx].plist;