summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2015-03-02 09:43:20 +0000
committerLiong Sauw Ming <ming@teluu.com>2015-03-02 09:43:20 +0000
commit29f035e34a157bbc553f236430586ea0eca64766 (patch)
tree73988056e4e2b5f44d7bf7113a2437dd9b9f013d /pjsip
parent241c5d358dc228badfcd832c64ff63ff9eb06674 (diff)
Fixed #1817: Automatically send BYE when sending CANCEL for INVITE is unsuccessful.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4986 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsua-lib/pjsua_internal.h1
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c19
2 files changed, 19 insertions, 1 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h
index bffe07f6..91b68d50 100644
--- a/pjsip/include/pjsua-lib/pjsua_internal.h
+++ b/pjsip/include/pjsua-lib/pjsua_internal.h
@@ -144,6 +144,7 @@ struct pjsua_call
/**< Array of provisional media. */
pj_bool_t med_update_success;
/**< Is media update successful? */
+ pj_bool_t hanging_up;/**< Is call in the process of hangup? */
int audio_idx; /**< First active audio media. */
pj_mutex_t *med_ch_mutex;/**< Media channel callback's mutex. */
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index 3f822a32..eeba99fe 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -2279,6 +2279,8 @@ PJ_DEF(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
if (status != PJ_SUCCESS)
goto on_return;
+ call->hanging_up = PJ_TRUE;
+
/* If media transport creation is not yet completed, we will hangup
* the call in the media transport creation callback instead.
*/
@@ -2312,6 +2314,7 @@ PJ_DEF(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
pjsua_perror(THIS_FILE,
"Failed to create end session message",
status);
+ call->hanging_up = PJ_FALSE;
goto on_return;
}
@@ -2331,6 +2334,7 @@ PJ_DEF(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
pjsua_perror(THIS_FILE,
"Failed to send end session message",
status);
+ call->hanging_up = PJ_FALSE;
goto on_return;
}
@@ -3812,6 +3816,9 @@ static void pjsua_call_on_media_update(pjsip_inv_session *inv,
call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id];
+ if (call->hanging_up)
+ goto on_return;
+
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "SDP negotiation has failed", status);
@@ -4734,7 +4741,17 @@ static void pjsua_call_on_tsx_state_changed(pjsip_inv_session *inv,
(tsx->status_code!=401 && tsx->status_code!=407 &&
tsx->status_code!=422))
{
- if (tsx->status_code/100 != 2) {
+ if (tsx->status_code/100 == 2) {
+ /* If we have sent CANCEL and the original INVITE returns a 2xx,
+ * we then send BYE.
+ */
+ if (call->hanging_up) {
+ PJ_LOG(3,(THIS_FILE, "Unsuccessful in cancelling the original "
+ "INVITE for call %d due to %d response, sending BYE "
+ "instead", call->index, tsx->status_code));
+ call_disconnect(call->inv, PJSIP_SC_OK);
+ }
+ } else {
/* Monitor the status of call hold/unhold request */
if (tsx->last_tx == (pjsip_tx_data*)call->hold_msg) {
/* Outgoing call hold failed */