Skip to content

Commit

Permalink
presence: more verbose debug message when failing to delete item from…
Browse files Browse the repository at this point in the history
… memory

- re-ordered comparison expression to check first lengths
  • Loading branch information
miconda committed Jan 2, 2015
1 parent 5573fde commit 497777e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 6 additions & 6 deletions modules/presence/hash.c
Expand Up @@ -287,12 +287,12 @@ int delete_shtable(shtable_t htable,unsigned int hash_code,subs_t* subs)

while(s)
{
if(s->callid.len==subs->callid.len &&
strncmp(s->callid.s, subs->callid.s, subs->callid.len)==0 &&
s->to_tag.len== subs->to_tag.len &&
strncmp(s->to_tag.s, subs->to_tag.s, subs->to_tag.len)==0 &&
s->from_tag.len== subs->from_tag.len &&
strncmp(s->from_tag.s, subs->from_tag.s, subs->from_tag.len)== 0)
if(s->callid.len==subs->callid.len
&& s->to_tag.len==subs->to_tag.len
&& s->from_tag.len==subs->from_tag.len
&& strncmp(s->callid.s,subs->callid.s,subs->callid.len)==0
&& strncmp(s->to_tag.s,subs->to_tag.s,subs->to_tag.len)==0
&& strncmp(s->from_tag.s,subs->from_tag.s,subs->from_tag.len)==0)
{
found= s->local_cseq +1;
ps->next= s->next;
Expand Down
12 changes: 8 additions & 4 deletions modules/presence/subscribe.c
Expand Up @@ -457,19 +457,23 @@ void delete_subs(str* pres_uri, str* ev_name, str* to_tag,
str* from_tag, str* callid)
{
subs_t subs;

memset(&subs, 0, sizeof(subs_t));

subs.pres_uri = *pres_uri;
subs.from_tag = *from_tag;
subs.to_tag = *to_tag;
subs.callid = *callid;

/* delete record from hash table also if not in dbonly mode */
if(subs_dbmode != DB_ONLY)
{
unsigned int hash_code= core_hash(pres_uri, ev_name, shtable_size);
if(delete_shtable(subs_htable, hash_code, &subs) < 0)
LM_ERR("Failed to delete subscription from memory\n");
if(delete_shtable(subs_htable, hash_code, &subs) < 0) {
LM_ERR("Failed to delete subscription from memory"
" [%.*s : %.*s / %.*s / %.*s]\n", ev_name->len, ev_name->s,
callid->len, callid->s, from_tag->len, from_tag->s,
to_tag->len, to_tag->s);
}
}

if(subs_dbmode != NO_DB && delete_db_subs(to_tag, from_tag, callid)< 0)
Expand Down

0 comments on commit 497777e

Please sign in to comment.