]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
manually handle bye to delay the 200 OK till after the call is torn down (reversable...
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 2 Jul 2009 17:40:16 +0000 (17:40 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 2 Jul 2009 17:40:16 +0000 (17:40 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14121 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c

index d6233bd9e71666a2136d740096375f631b86fcd9..e1dbcaf7bc6b18f601fefc0dda42f437a6c98393 100644 (file)
@@ -36,6 +36,8 @@
 
 /*Defines etc..*/
 /*************************************************************************************************************************************************************/
+#define MANUAL_BYE
+
 #define IREG_SECONDS 30
 #define GATEWAY_SECONDS 1
 #define SOFIA_QUEUE_SIZE 50000
index 5efec16bad738a12a8d2061c5491436eb59f5406..15632287d73b0b39f6573013264b20176923807e 100644 (file)
@@ -281,6 +281,10 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
        const char *tmp;
        switch_channel_t *channel;
        private_object_t *tech_pvt;
+#ifdef MANUAL_BYE
+       int cause;
+       char st[80] = "";
+#endif
 
        if (!session)
                return;
@@ -288,11 +292,41 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
        channel = switch_core_session_get_channel(session);
        tech_pvt = switch_core_session_get_private(session);
 
+
+#ifdef MANUAL_BYE
+       status = 200;
+       phrase = "OK";
+       
+       sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
+
        if (sip->sip_reason && sip->sip_reason->re_protocol &&
                (!strcasecmp(sip->sip_reason->re_protocol, "Q.850") || !strcasecmp(sip->sip_reason->re_protocol, "FreeSWITCH")) && sip->sip_reason->re_cause) {
                tech_pvt->q850_cause = atoi(sip->sip_reason->re_cause);
+               cause = tech_pvt->q850_cause;
+       } else {
+               cause = sofia_glue_sip_cause_to_freeswitch(status);
+       }
+
+       switch_snprintf(st, sizeof(st), "%d", status);
+       switch_channel_set_variable(channel, "sip_term_status", st);
+       switch_snprintf(st, sizeof(st), "sip:%d", status);
+
+       if (phrase) {
+               switch_channel_set_variable_partner(channel, "sip_hangup_phrase", phrase);
        }
 
+       switch_snprintf(st, sizeof(st), "%d", cause);
+       switch_channel_set_variable(channel, "sip_term_cause", st);
+       switch_channel_hangup(channel, cause);
+       nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
+
+       if (sofia_private) {
+        sofia_private->destroy_me = 1;
+        sofia_private->destroy_nh = 1;
+    }
+#endif
+
+
        if (sip->sip_user_agent && !switch_strlen_zero(sip->sip_user_agent->g_string)) {
                switch_channel_set_variable(channel, "sip_user_agent", sip->sip_user_agent->g_string);
        } else if (sip->sip_server && !switch_strlen_zero(sip->sip_server->g_string)) {
@@ -310,8 +344,8 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
        }
        
        tech_pvt->got_bye = 1;
-       switch_channel_set_variable(channel, "sip_hangup_disposition", "recv_bye");
-       
+       switch_channel_set_variable(channel, "sip_hangup_disposition", "recv_bye");     
+
        return;
 }
 
@@ -813,6 +847,9 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
                                   NUTAG_APPL_METHOD("OPTIONS"),
                                   NUTAG_APPL_METHOD("NOTIFY"),
                                   NUTAG_APPL_METHOD("INFO"),
+#ifdef MANUAL_BYE
+                                  NUTAG_APPL_METHOD("BYE"),
+#endif
                                   NUTAG_AUTOANSWER(0),
                                   NUTAG_AUTOALERT(0),
                                   NUTAG_ENABLEMESSENGER(1),