From 1a66e8b288f0f566ba4c6be002e0e3e30fdccf4c Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 16 Sep 2008 20:04:33 +0000 Subject: [PATCH] omit chat_hash code when presence is not enabled git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9574 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/sofia.c | 2 ++ src/mod/endpoints/mod_sofia/sofia_glue.c | 8 ++++++-- src/mod/endpoints/mod_sofia/sofia_presence.c | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 47cf0eb016..2d73668083 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -3782,7 +3782,9 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ } if (tech_pvt->hash_key) { + switch_mutex_lock(tech_pvt->profile->flag_mutex); switch_core_hash_delete(tech_pvt->profile->chat_hash, tech_pvt->hash_key); + switch_mutex_unlock(tech_pvt->profile->flag_mutex); } nua_handle_bind(nh, NULL); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 555ed742ec..d1e104dd1b 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1231,8 +1231,12 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) tech_pvt->chat_from = tech_pvt->from_str; tech_pvt->chat_to = tech_pvt->dest; - tech_pvt->hash_key = switch_core_session_strdup(tech_pvt->session, hash_key); - switch_core_hash_insert(tech_pvt->profile->chat_hash, tech_pvt->hash_key, tech_pvt); + if (tech_pvt->profile->pflags & PFLAG_PRESENCE) { + tech_pvt->hash_key = switch_core_session_strdup(tech_pvt->session, hash_key); + switch_mutex_lock(tech_pvt->profile->flag_mutex); + switch_core_hash_insert(tech_pvt->profile->chat_hash, tech_pvt->hash_key, tech_pvt); + switch_mutex_unlock(tech_pvt->profile->flag_mutex); + } free(e_dest); } diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index cfbd64a393..bf7bc8d10d 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -1724,10 +1724,11 @@ void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip) } else { return; } - + + switch_mutex_lock(tech_pvt->profile->flag_mutex); tech_pvt->hash_key = switch_core_session_strdup(tech_pvt->session, hash_key); switch_core_hash_insert(tech_pvt->profile->chat_hash, tech_pvt->hash_key, tech_pvt); - + switch_mutex_unlock(tech_pvt->profile->flag_mutex); } /* For Emacs: