<div dir="ltr">Hey all,<div><br></div><div>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:</div><div><br></div>
<div><div><font face="courier new, monospace">int delete_shtable(shtable_t htable,unsigned int hash_code,str to_tag)</font></div><div><font face="courier new, monospace">{</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">      </span>subs_t* s= NULL, *ps= NULL;</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>int found= -1;</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">  </span>lock_get(&htable[hash_code].lock);</font></div>
<div><span class="" style="white-space:pre"><font face="courier new, monospace">        </font></span></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">  </span>ps= htable[hash_code].entries;</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>s= ps->next;</font></div><div><span class="" style="white-space:pre"><font face="courier new, monospace">           </font></span></div><div>
<font face="courier new, monospace"><span class="" style="white-space:pre">   </span>while(s)</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">  </span>{</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">         </span><font color="#ff0000">if(s->to_tag.len== to_tag.len &&</font></font></div>
<div><font color="#ff0000" face="courier new, monospace"><span class="" style="white-space:pre">                              </span>strncmp(s->to_tag.s, to_tag.s, to_tag.len)== 0)</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>{</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                        </span>found= s->local_cseq +1;</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                       </span>ps->next= s->next;</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                        </span>if(s->contact.s!=NULL)</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                         </span>shm_free(s->contact.s);</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                        </span>shm_free(s);</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                      </span>break;</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>}</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">         </span>ps= s;</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">            </span>s= s->next;</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>lock_release(&htable[hash_code].lock);</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>return found;</font></div><div><font face="courier new, monospace">}</font></div></div><div><br></div><div>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...</div>
<div><br></div><div>any comments? Am I missing something here?</div><div><br></div><div>Cheers</div><div>jason</div></div>