]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add error handling for when we get response to a invite that we don't have a session...
authorMichael Jerris <mike@jerris.com>
Fri, 10 Oct 2008 22:22:41 +0000 (22:22 +0000)
committerMichael Jerris <mike@jerris.com>
Fri, 10 Oct 2008 22:22:41 +0000 (22:22 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9947 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/sofia.c

index f93d456eaba346f862368625b616c0b11012cfd5..7dfc3b989242fd0b623fdcb776da813fb2e2b7e8 100644 (file)
@@ -2149,6 +2149,29 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
                        }
                }
        }
+
+       if (!session && (status == 180 || status == 183 || status == 200)) {
+               /* This should never happen.  It means the sip stack thinks there is a call but FreeSWITCH does not */
+               const char *callid = "n/a";
+
+               if (sip && sip->sip_call_id && sip->sip_call_id->i_id) callid = sip->sip_call_id->i_id;
+
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "received response to invite with no matching session, destroying callid [%s]!\n", callid);
+
+               if (nh) {
+                       if (status == 200) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending BYE to orphan call.\n");
+                               nua_bye(nh, TAG_END());
+                       } else {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending CANCEL to orphan call.\n");
+                               nua_cancel(nh, TAG_END());
+                       }
+
+                       nua_handle_bind(nh, NULL);
+                       nua_handle_destroy(nh);
+               }
+
+       }
 }