[asterisk-commits] file: trunk r404653 - in /trunk: ./ channels/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 31 16:51:05 CST 2013


Author: file
Date: Tue Dec 31 16:51:04 2013
New Revision: 404653

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404653
Log:
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

Modified:
    trunk/   (props changed)
    trunk/channels/chan_pjsip.c
    trunk/res/res_pjsip_session.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Tue Dec 31 16:51:04 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404568,404581,404592,404605,404613
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404568,404581,404592,404605,404613,404652

Modified: trunk/channels/chan_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_pjsip.c?view=diff&rev=404653&r1=404652&r2=404653
==============================================================================
--- trunk/channels/chan_pjsip.c (original)
+++ trunk/channels/chan_pjsip.c Tue Dec 31 16:51:04 2013
@@ -1429,8 +1429,6 @@
 
 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 @@
 	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);
+			}
 		}
 	}
 

Modified: trunk/res/res_pjsip_session.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_session.c?view=diff&rev=404653&r1=404652&r2=404653
==============================================================================
--- trunk/res/res_pjsip_session.c (original)
+++ trunk/res/res_pjsip_session.c Tue Dec 31 16:51:04 2013
@@ -1826,14 +1826,20 @@
 static void session_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e)
 {
 	struct ast_sip_session *session = inv->mod_data[session_module.id];
-
-	print_debug_details(inv, NULL, e);
+	pjsip_event_id_e type;
+
+	if (e) {
+		print_debug_details(inv, NULL, e);
+		type = e->type;
+	} else {
+		type = PJSIP_EVENT_UNKNOWN;
+	}
 
 	if (!session) {
 		return;
 	}
 
-	switch(e->type) {
+	switch(type) {
 	case PJSIP_EVENT_TX_MSG:
 		handle_outgoing(session, e->body.tx_msg.tdata);
 		break;




More information about the asterisk-commits mailing list