From: Giovanni Maruzzelli Date: Sat, 21 May 2011 07:45:39 +0000 (-0500) Subject: skypopen: adding some guards against NULL sessions and channels X-Git-Tag: v1.2-rc1~118^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2146583663a5067f6ff71df1e48c3bb900e89db8;p=thirdparty%2Ffreeswitch.git skypopen: adding some guards against NULL sessions and channels --- diff --git a/src/mod/endpoints/mod_skypopen/skypopen_protocol.c b/src/mod/endpoints/mod_skypopen/skypopen_protocol.c index 391a23caaf..4f5f129344 100644 --- a/src/mod/endpoints/mod_skypopen/skypopen_protocol.c +++ b/src/mod/endpoints/mod_skypopen/skypopen_protocol.c @@ -1739,19 +1739,23 @@ void *skypopen_do_skypeapi_thread_func(void *obj) if (session) { switch_channel_t *channel = switch_core_session_get_channel(session); + if(channel){ - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_IO); - switch_clear_flag(tech_pvt, TFLAG_VOICE); - if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { - switch_clear_flag(tech_pvt, TFLAG_PROGRESS); - } - switch_mutex_unlock(tech_pvt->flag_mutex); + switch_mutex_lock(tech_pvt->flag_mutex); + switch_clear_flag(tech_pvt, TFLAG_IO); + switch_clear_flag(tech_pvt, TFLAG_VOICE); + if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { + switch_clear_flag(tech_pvt, TFLAG_PROGRESS); + } + switch_mutex_unlock(tech_pvt->flag_mutex); - switch_core_session_rwunlock(session); - WARNINGA("Closing session for %s\n", SKYPOPEN_P_LOG, interfacename); - switch_channel_hangup(channel, SWITCH_CAUSE_CRASH); + switch_core_session_rwunlock(session); + WARNINGA("Closing session for %s\n", SKYPOPEN_P_LOG, interfacename); + switch_channel_hangup(channel, SWITCH_CAUSE_CRASH); + } else { + WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG); + } } WARNINGA("Removing skype interface %s\n", SKYPOPEN_P_LOG, interfacename); @@ -1772,19 +1776,23 @@ void *skypopen_do_skypeapi_thread_func(void *obj) switch_channel_t *channel = switch_core_session_get_channel(session); - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_IO); - switch_clear_flag(tech_pvt, TFLAG_VOICE); - if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { - switch_clear_flag(tech_pvt, TFLAG_PROGRESS); - } - switch_mutex_unlock(tech_pvt->flag_mutex); + if(channel){ + switch_mutex_lock(tech_pvt->flag_mutex); + switch_clear_flag(tech_pvt, TFLAG_IO); + switch_clear_flag(tech_pvt, TFLAG_VOICE); + if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { + switch_clear_flag(tech_pvt, TFLAG_PROGRESS); + } + switch_mutex_unlock(tech_pvt->flag_mutex); - switch_core_session_rwunlock(session); - WARNINGA("Closing session for %s\n", SKYPOPEN_P_LOG, interfacename); - switch_channel_hangup(channel, SWITCH_CAUSE_CRASH); + switch_core_session_rwunlock(session); + WARNINGA("Closing session for %s\n", SKYPOPEN_P_LOG, interfacename); + switch_channel_hangup(channel, SWITCH_CAUSE_CRASH); + } else { + WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG); + } //skypopen_sleep(500000); }