From 497777e042166e441767101db05c85ad69c13722 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Fri, 2 Jan 2015 13:41:44 +0100 Subject: [PATCH] presence: more verbose debug message when failing to delete item from memory - re-ordered comparison expression to check first lengths --- modules/presence/hash.c | 12 ++++++------ modules/presence/subscribe.c | 12 ++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/presence/hash.c b/modules/presence/hash.c index ed1a1886271..4c6f18149bf 100644 --- a/modules/presence/hash.c +++ b/modules/presence/hash.c @@ -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; diff --git a/modules/presence/subscribe.c b/modules/presence/subscribe.c index 9c9b9acfd49..172372de99b 100644 --- a/modules/presence/subscribe.c +++ b/modules/presence/subscribe.c @@ -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)