diff --git a/src/switch_channel.c b/src/switch_channel.c index 6e22b82d75..b32815aceb 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -3160,6 +3160,10 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan } switch_mutex_unlock(channel->state_mutex); + if (switch_channel_test_flag(channel, CF_LEG_HOLDING)) { + switch_channel_mark_hold(channel, SWITCH_FALSE); + } + if (!ok) { return channel->state; } diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index e81d4787c9..60c74e281b 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -647,21 +647,24 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a), SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a)); switch_channel_clear_flag(chan_a, CF_BRIDGED); - if (switch_channel_test_flag(chan_a, CF_LEG_HOLDING) && switch_channel_ready(chan_b) && switch_channel_get_state(chan_b) != CS_PARK) { - const char *ext = switch_channel_get_variable(chan_a, "hold_hangup_xfer_exten"); + if (switch_channel_test_flag(chan_a, CF_LEG_HOLDING)) { - switch_channel_stop_broadcast(chan_b); + if (switch_channel_ready(chan_b) && switch_channel_get_state(chan_b) != CS_PARK) { + const char *ext = switch_channel_get_variable(chan_a, "hold_hangup_xfer_exten"); - if (zstr(ext)) { - switch_call_cause_t cause = switch_channel_get_cause(chan_b); - if (cause == SWITCH_CAUSE_NONE) { - cause = SWITCH_CAUSE_NORMAL_CLEARING; + switch_channel_stop_broadcast(chan_b); + + if (zstr(ext)) { + switch_call_cause_t cause = switch_channel_get_cause(chan_b); + if (cause == SWITCH_CAUSE_NONE) { + cause = SWITCH_CAUSE_NORMAL_CLEARING; + } + switch_channel_hangup(chan_b, cause); + } else { + switch_channel_set_variable(chan_b, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE, ext); } - switch_channel_hangup(chan_b, cause); - } else { - switch_channel_set_variable(chan_b, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE, ext); } - switch_channel_clear_flag(chan_a, CF_LEG_HOLDING); + switch_channel_mark_hold(chan_a, SWITCH_FALSE); } if (switch_channel_test_flag(chan_a, CF_INTERCEPTED)) {