res_pjsip_session.c: Reorganize ast_sip_session_terminate().

Change-Id: I68a2128bcba4830985d2d441e70dfd1ac5bd712b
changes/17/3017/1
Richard Mudgett 9 years ago
parent d9b5aea9c3
commit 3d0632a9c2

@ -1794,17 +1794,24 @@ void ast_sip_session_terminate(struct ast_sip_session *session, int response)
response = 603; response = 603;
} }
if ((session->inv_session->state == PJSIP_INV_STATE_CONFIRMED) && session->inv_session->invite_tsx) { switch (session->inv_session->state) {
case PJSIP_INV_STATE_NULL:
pjsip_inv_terminate(session->inv_session, response, PJ_TRUE);
break;
case PJSIP_INV_STATE_CONFIRMED:
if (session->inv_session->invite_tsx) {
ast_debug(3, "Delay sending BYE to %s because of outstanding transaction...\n", ast_debug(3, "Delay sending BYE to %s because of outstanding transaction...\n",
ast_sorcery_object_get_id(session->endpoint)); ast_sorcery_object_get_id(session->endpoint));
/* If this is delayed the only thing that will happen is a BYE request so we don't /* If this is delayed the only thing that will happen is a BYE request so we don't
* actually need to store the response code for when it happens. * actually need to store the response code for when it happens.
*/ */
delay_request(session, NULL, NULL, NULL, 0, DELAYED_METHOD_BYE); delay_request(session, NULL, NULL, NULL, 0, DELAYED_METHOD_BYE);
} else if (session->inv_session->state == PJSIP_INV_STATE_NULL) { break;
pjsip_inv_terminate(session->inv_session, response, PJ_TRUE); }
} else if (((status = pjsip_inv_end_session(session->inv_session, response, NULL, &packet)) == PJ_SUCCESS) /* Fall through */
&& packet) { default:
status = pjsip_inv_end_session(session->inv_session, response, NULL, &packet);
if (status == PJ_SUCCESS && packet) {
struct ast_sip_session_delayed_request *delay; struct ast_sip_session_delayed_request *delay;
/* Flush any delayed requests so they cannot overlap this transaction. */ /* Flush any delayed requests so they cannot overlap this transaction. */
@ -1818,6 +1825,8 @@ void ast_sip_session_terminate(struct ast_sip_session *session, int response)
ast_sip_session_send_request(session, packet); ast_sip_session_send_request(session, packet);
} }
} }
break;
}
} }
static int session_termination_task(void *data) static int session_termination_task(void *data)

Loading…
Cancel
Save