From 2146583663a5067f6ff71df1e48c3bb900e89db8 Mon Sep 17 00:00:00 2001 From: Giovanni Maruzzelli Date: Sat, 21 May 2011 02:45:39 -0500 Subject: [PATCH] skypopen: adding some guards against NULL sessions and channels --- .../mod_skypopen/skypopen_protocol.c | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) 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_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); + } else { + WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG); } - 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); } 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); + 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); + + } else { + WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG); } - 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); - //skypopen_sleep(500000); }