skypopen: adding some guards against NULL sessions and channels

This commit is contained in:
Giovanni Maruzzelli 2011-05-21 02:45:39 -05:00
parent b65a3ebd18
commit 2146583663

View File

@ -1739,6 +1739,7 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
if (session) { if (session) {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
if(channel){
switch_mutex_lock(tech_pvt->flag_mutex); switch_mutex_lock(tech_pvt->flag_mutex);
switch_clear_flag(tech_pvt, TFLAG_IO); switch_clear_flag(tech_pvt, TFLAG_IO);
@ -1752,6 +1753,9 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
switch_core_session_rwunlock(session); switch_core_session_rwunlock(session);
WARNINGA("Closing session for %s\n", SKYPOPEN_P_LOG, interfacename); WARNINGA("Closing session for %s\n", SKYPOPEN_P_LOG, interfacename);
switch_channel_hangup(channel, SWITCH_CAUSE_CRASH); 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); WARNINGA("Removing skype interface %s\n", SKYPOPEN_P_LOG, interfacename);
@ -1772,6 +1776,7 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
if(channel){
switch_mutex_lock(tech_pvt->flag_mutex); switch_mutex_lock(tech_pvt->flag_mutex);
switch_clear_flag(tech_pvt, TFLAG_IO); switch_clear_flag(tech_pvt, TFLAG_IO);
switch_clear_flag(tech_pvt, TFLAG_VOICE); switch_clear_flag(tech_pvt, TFLAG_VOICE);
@ -1785,6 +1790,9 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
WARNINGA("Closing session for %s\n", SKYPOPEN_P_LOG, interfacename); WARNINGA("Closing session for %s\n", SKYPOPEN_P_LOG, interfacename);
switch_channel_hangup(channel, SWITCH_CAUSE_CRASH); switch_channel_hangup(channel, SWITCH_CAUSE_CRASH);
} else {
WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG);
}
//skypopen_sleep(500000); //skypopen_sleep(500000);
} }