From 3cfd874ebe475bd20987f0573c66592ecba2e502 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 29 Jan 2010 22:15:05 +0000 Subject: [PATCH] try this git-svn-id: http://svn.openzap.org/svn/openzap/trunk@1011 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/openzap/mod_openzap/mod_openzap.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libs/openzap/mod_openzap/mod_openzap.c b/libs/openzap/mod_openzap/mod_openzap.c index c94fff67a4..ef6f183cf6 100644 --- a/libs/openzap/mod_openzap/mod_openzap.c +++ b/libs/openzap/mod_openzap/mod_openzap.c @@ -462,6 +462,9 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session) tech_pvt = switch_core_session_get_private(session); assert(tech_pvt != NULL); + if (!tech_pvt->zchan) { + goto end; + } zap_channel_clear_token(tech_pvt->zchan, switch_core_session_get_uuid(session)); @@ -505,6 +508,8 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session) break; } + end: + switch_clear_flag_locked(tech_pvt, TFLAG_IO); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel)); @@ -1358,7 +1363,10 @@ static ZIO_SIGNAL_CB_FUNCTION(on_fxo_signal) break; case ZAP_SIGEVENT_STOP: { + private_t *tech_pvt = NULL; while((session = zap_channel_get_session(sigmsg->channel, 0))) { + tech_pvt = switch_core_session_get_private(session); + tech_pvt->zchan = NULL; zap_channel_clear_token(sigmsg->channel, 0); channel = switch_core_session_get_channel(session); switch_channel_hangup(channel, sigmsg->channel->caller_data.hangup_cause); @@ -1435,6 +1443,7 @@ static ZIO_SIGNAL_CB_FUNCTION(on_fxs_signal) break; case ZAP_SIGEVENT_STOP: { + private_t *tech_pvt = NULL; switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING; if (sigmsg->channel->token_count) { switch_core_session_t *session_a, *session_b, *session_t = NULL; @@ -1490,6 +1499,8 @@ static ZIO_SIGNAL_CB_FUNCTION(on_fxs_signal) } while((session = zap_channel_get_session(sigmsg->channel, 0))) { + tech_pvt = switch_core_session_get_private(session); + tech_pvt->zchan = NULL; channel = switch_core_session_get_channel(session); switch_channel_hangup(channel, cause); zap_channel_clear_token(sigmsg->channel, switch_core_session_get_uuid(session)); @@ -1616,7 +1627,10 @@ static ZIO_SIGNAL_CB_FUNCTION(on_r2_signal) /* on_call_disconnect from the R2 side */ case ZAP_SIGEVENT_STOP: { + private_t *tech_pvt = NULL; while((session = zap_channel_get_session(sigmsg->channel, 0))) { + tech_pvt = switch_core_session_get_private(session); + tech_pvt->zchan = NULL; channel = switch_core_session_get_channel(session); switch_channel_hangup(channel, sigmsg->channel->caller_data.hangup_cause); zap_channel_clear_token(sigmsg->channel, switch_core_session_get_uuid(session)); @@ -1726,7 +1740,10 @@ static ZIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal) case ZAP_SIGEVENT_STOP: case ZAP_SIGEVENT_RESTART: { + private_t *tech_pvt = NULL; while((session = zap_channel_get_session(sigmsg->channel, 0))) { + tech_pvt = switch_core_session_get_private(session); + tech_pvt->zchan = NULL; channel = switch_core_session_get_channel(session); switch_channel_hangup(channel, sigmsg->channel->caller_data.hangup_cause); zap_channel_clear_token(sigmsg->channel, switch_core_session_get_uuid(session));