diff options
author | Joshua Colp <jcolp@digium.com> | 2013-12-31 22:51:04 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2013-12-31 22:51:04 +0000 |
commit | f720a9ac89f2045f4a60325b661ce85afec95081 (patch) | |
tree | 1696346739424c2f87fad9fe128e406a6c5b6658 /channels/chan_pjsip.c | |
parent | e583dca9dd7823489067a67311d30583ba1ad3c6 (diff) |
chan_pjsip: Handle hanging up before calling.
Channel creation in Asterisk is broken up into two steps: requesting and calling.
In some cases a channel may be requested but never called. This happens in the
ChanIsAvail dialplan application for determining if something is reachable or
not. The PJSIP channel driver did not take this situation into account and
attempted to end a session that was never called out on.
The code now checks the session state to determine if the session has been
called out on and if not terminates it instead of ending it.
(closes issue ASTERISK-23074)
Reported by: Kilburn
........
Merged revisions 404652 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404653 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_pjsip.c')
-rw-r--r-- | channels/chan_pjsip.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c index a560d7706..0fbfd9ea5 100644 --- a/channels/chan_pjsip.c +++ b/channels/chan_pjsip.c @@ -1429,8 +1429,6 @@ static void clear_session_and_channel(struct ast_sip_session *session, struct as static int hangup(void *data) { - pj_status_t status; - pjsip_tx_data *packet = NULL; struct hangup_data *h_data = data; struct ast_channel *ast = h_data->chan; struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast); @@ -1438,12 +1436,19 @@ static int hangup(void *data) struct ast_sip_session *session = channel->session; int cause = h_data->cause; - if (!session->defer_terminate && - ((status = pjsip_inv_end_session(session->inv_session, cause ? cause : 603, NULL, &packet)) == PJ_SUCCESS) && packet) { - if (packet->msg->type == PJSIP_RESPONSE_MSG) { - ast_sip_session_send_response(session, packet); - } else { - ast_sip_session_send_request(session, packet); + if (!session->defer_terminate) { + pj_status_t status; + pjsip_tx_data *packet = NULL; + + if (session->inv_session->state == PJSIP_INV_STATE_NULL) { + pjsip_inv_terminate(session->inv_session, cause ? cause : 603, PJ_TRUE); + } else if (((status = pjsip_inv_end_session(session->inv_session, cause ? cause : 603, NULL, &packet)) == PJ_SUCCESS) + && packet) { + if (packet->msg->type == PJSIP_RESPONSE_MSG) { + ast_sip_session_send_response(session, packet); + } else { + ast_sip_session_send_request(session, packet); + } } } |