From cd88211d0a8cac10e9c111687066e65d2bc9abd6 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 26 Jul 2012 14:33:45 -0500 Subject: [PATCH] FS-4470 try this, the tmp_hanguphook will flag the b leg with CF_REDIRECT in the event that it hangs up which should spare it from the codepath in exchange_media state --- .../applications/mod_dptools/mod_dptools.c | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 7abd30a6bb..4b46e7eec3 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -2126,6 +2126,32 @@ static switch_status_t xfer_on_dtmf(switch_core_session_t *session, void *input, return SWITCH_STATUS_SUCCESS; } +static switch_status_t tmp_hanguphook(switch_core_session_t *session) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_channel_state_t state = switch_channel_get_state(channel); + + if (state == CS_HANGUP || state == CS_ROUTING) { + const char *bond = switch_channel_get_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE); + + if (!zstr(bond)) { + switch_core_session_t *b_session; + + if ((b_session = switch_core_session_locate(bond))) { + switch_channel_t *b_channel = switch_core_session_get_channel(b_session); + if (switch_channel_up(b_channel)) { + switch_channel_set_flag(b_channel, CF_REDIRECT); + } + switch_core_session_rwunlock(b_session); + } + } + + switch_core_event_hook_remove_state_change(session, tmp_hanguphook); + } + + return SWITCH_STATUS_SUCCESS; +} + static switch_status_t hanguphook(switch_core_session_t *session) { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -2160,14 +2186,13 @@ SWITCH_STANDARD_APP(att_xfer_function) switch_channel_t *channel, *peer_channel = NULL; const char *bond = NULL; switch_core_session_t *b_session = NULL; - + channel = switch_core_session_get_channel(session); - if ((bond = switch_channel_get_partner_uuid(channel))) { - bond = switch_core_session_strdup(session, bond); - } - + bond = switch_channel_get_partner_uuid(channel); switch_channel_set_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, bond); + switch_core_event_hook_add_state_change(session, tmp_hanguphook); + if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS || !peer_session) { @@ -2226,6 +2251,9 @@ SWITCH_STANDARD_APP(att_xfer_function) switch_core_session_rwunlock(peer_session); end: + + switch_core_event_hook_remove_state_change(session, tmp_hanguphook); + switch_channel_set_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, NULL); switch_channel_clear_flag(channel, CF_XFER_ZOMBIE); }