]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add more error case handling to crazy transfer support
authorMichael Jerris <mike@jerris.com>
Fri, 12 Sep 2008 00:05:09 +0000 (00:05 +0000)
committerMichael Jerris <mike@jerris.com>
Fri, 12 Sep 2008 00:05:09 +0000 (00:05 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9531 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/sofia.c

index d812db87cc72152f5f894044680d25b0d564b7ea..90dd00f22677cd415f7a22a15bc3f528cdf557f9 100644 (file)
@@ -2636,21 +2636,24 @@ void *SWITCH_THREAD_FUNC nightmare_xfer_thread_run(switch_thread_t *thread, void
 
                        status = switch_ivr_originate(a_session, &tsession, &cause, nhelper->exten, timeout, NULL, NULL, NULL, NULL, SOF_NONE);
                                                        
-                       if (status != SWITCH_STATUS_SUCCESS || cause != SWITCH_CAUSE_SUCCESS) {
-                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel! [%s]\n", nhelper->exten);
-                               nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("messsage/sipfrag"),
-                                                  NUTAG_SUBSTATE(nua_substate_terminated),
-                                                  SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"), SIPTAG_EVENT_STR(nhelper->event), TAG_END());
-                               status = SWITCH_STATUS_FALSE;
-                       } else {
+                       if ((switch_channel_get_state(channel_a) < CS_HANGUP)) {
+                               
+                               if (status != SWITCH_STATUS_SUCCESS || cause != SWITCH_CAUSE_SUCCESS) {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel! [%s]\n", nhelper->exten);
+                                       nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("messsage/sipfrag"),
+                                                          NUTAG_SUBSTATE(nua_substate_terminated),
+                                                          SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"), SIPTAG_EVENT_STR(nhelper->event), TAG_END());
+                                       status = SWITCH_STATUS_FALSE;
+                               } else {
 
-                               tuuid_str = switch_core_session_get_uuid(tsession);
-                               switch_ivr_uuid_bridge(nhelper->bridge_to_uuid, tuuid_str);
-                               switch_channel_set_variable(channel_a, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
-                               switch_set_flag_locked(tech_pvt, TFLAG_BYE);
-                               nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
-                                                  NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(nhelper->event), TAG_END());
-                               switch_core_session_rwunlock(tsession);
+                                       tuuid_str = switch_core_session_get_uuid(tsession);
+                                       switch_ivr_uuid_bridge(nhelper->bridge_to_uuid, tuuid_str);
+                                       switch_channel_set_variable(channel_a, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
+                                       switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+                                       nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
+                                                          NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(nhelper->event), TAG_END());
+                                       switch_core_session_rwunlock(tsession);
+                               }
                        }
                        switch_core_session_rwunlock(session);
                }