[sr-dev] presence module (API)

Jason Penton jason.penton at gmail.com
Thu Jan 23 15:19:13 CET 2014


Hey all,

I was taking a look at the presence module API code, specfically the API
code for the hash table. I see that when we delete a subscription according
to hash.c:

int delete_shtable(shtable_t htable,unsigned int hash_code,str to_tag)
{
subs_t* s= NULL, *ps= NULL;
int found= -1;

lock_get(&htable[hash_code].lock);
 ps= htable[hash_code].entries;
s= ps->next;
 while(s)
{
if(s->to_tag.len== to_tag.len &&
strncmp(s->to_tag.s, to_tag.s, to_tag.len)== 0)
{
found= s->local_cseq +1;
ps->next= s->next;
if(s->contact.s!=NULL)
shm_free(s->contact.s);
shm_free(s);
break;
}
ps= s;
s= s->next;
}
lock_release(&htable[hash_code].lock);
return found;
}

Why are we only searching on to-tag? What if there is a collision on the
hash AND the to-tag is the same for 2+ different subscriptions. This is
even more likely of happening considering that the hash calculation is
based only on the callid and to-tag...

any comments? Am I missing something here?

Cheers
jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20140123/4d7495be/attachment.html>


More information about the sr-dev mailing list