From 574d19e56ee2a624696364b6893be896615877a2 Mon Sep 17 00:00:00 2001
From: Nathan Neulinger <nneul@neulinger.org>
Date: Tue, 9 Sep 2014 15:58:56 -0500
Subject: [PATCH] mod_skinny: fix behavior of transfer when target extension
 falls through to voicemail - keep bridge from dropping out during that
 operation

---
 src/mod/endpoints/mod_skinny/skinny_server.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c
index 7a241231a7..f54224640f 100644
--- a/src/mod/endpoints/mod_skinny/skinny_server.c
+++ b/src/mod/endpoints/mod_skinny/skinny_server.c
@@ -903,6 +903,7 @@ switch_status_t skinny_session_transfer(switch_core_session_t *session, listener
 	const char *remote_uuid = NULL;
 	const char *remote_uuid2 = NULL;
 	switch_core_session_t *session2 = NULL;
+	switch_core_session_t *rsession = NULL;
 	private_t *tech_pvt2 = NULL;
 
 	switch_assert(session);
@@ -914,6 +915,17 @@ switch_status_t skinny_session_transfer(switch_core_session_t *session, listener
 	local_uuid = switch_channel_get_uuid(channel);
 	remote_uuid = switch_channel_get_partner_uuid(channel);
 
+	if ( switch_core_session_get_partner(session, &rsession) == SWITCH_STATUS_SUCCESS )
+	{
+		switch_channel_t *rchannel = NULL;
+		rchannel = switch_core_session_get_channel(rsession);
+
+		skinny_log_l_msg(listener, SWITCH_LOG_INFO, "SST: setting uuid bridge continue flag on remote channel\n");
+
+		switch_channel_set_variable(rchannel, "uuid_bridge_continue_on_cancel", "true");
+		switch_core_session_rwunlock(rsession);
+	}
+
 	skinny_log_l(listener, SWITCH_LOG_INFO, "SST: local_uuid=%s remote_uuid=%s\n", local_uuid, remote_uuid);
 
 	if (tech_pvt->transfer_from_call_id) {
@@ -928,7 +940,7 @@ switch_status_t skinny_session_transfer(switch_core_session_t *session, listener
 
 			skinny_log_ls(listener, session2, SWITCH_LOG_INFO, "SST: attempting ivr bridge from (%s) to (%s)\n", remote_uuid, remote_uuid2);
 
-			if (switch_ivr_uuid_bridge(remote_uuid, remote_uuid2) == SWITCH_STATUS_SUCCESS) {
+			if (switch_ivr_uuid_bridge(remote_uuid2, remote_uuid) == SWITCH_STATUS_SUCCESS) {
 				skinny_log_ls_msg(listener, session2, SWITCH_LOG_INFO, "SST: success on uuid bridge\n");
 
 				switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);