[asterisk-commits] bebuild: branch certified-13.1 r429864 - in /certified/branches/13.1: ./ chan...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Dec 19 14:42:59 CST 2014
Author: bebuild
Date: Fri Dec 19 14:42:56 2014
New Revision: 429864
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=429864
Log:
res_pjsip_session: Delay sending BYE if a re-INVITE transaction is in progress.
Given the scenario where a PJSIP channel is in a native RTP bridge with direct
media and the channel is then hung up the code will currently re-INVITE the channel
back to Asterisk and send a BYE at the same time. Many SIP implementations dislike
this greatly.
This change makes it so that if a re-INVITE transaction is in progress the BYE
is queued to occur after the completion of the transaction (be it through normal
means or a timeout).
Review: https://reviewboard.asterisk.org/r/4248/
........
Merged revisions 429409 from http://svn.asterisk.org/svn/asterisk/branches/13
Modified:
certified/branches/13.1/ (props changed)
certified/branches/13.1/channels/chan_pjsip.c
certified/branches/13.1/include/asterisk/res_pjsip_session.h
certified/branches/13.1/res/res_pjsip_session.c
certified/branches/13.1/res/res_pjsip_session.exports.in
Propchange: certified/branches/13.1/
------------------------------------------------------------------------------
--- branch-13-merged (original)
+++ branch-13-merged Fri Dec 19 14:42:56 2014
@@ -1,1 +1,1 @@
-/branches/13:429196,429477,429540,429571,429739,429829
+/branches/13:429196,429409,429477,429540,429571,429739,429829
Modified: certified/branches/13.1/channels/chan_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/channels/chan_pjsip.c?view=diff&rev=429864&r1=429863&r2=429864
==============================================================================
--- certified/branches/13.1/channels/chan_pjsip.c (original)
+++ certified/branches/13.1/channels/chan_pjsip.c Fri Dec 19 14:42:56 2014
@@ -1692,22 +1692,7 @@
struct ast_sip_session *session = channel->session;
int cause = h_data->cause;
- 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);
- }
- }
- }
-
+ ast_sip_session_terminate(session, cause);
clear_session_and_channel(session, ast, pvt);
ao2_cleanup(channel);
ao2_cleanup(h_data);
Modified: certified/branches/13.1/include/asterisk/res_pjsip_session.h
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/include/asterisk/res_pjsip_session.h?view=diff&rev=429864&r1=429863&r2=429864
==============================================================================
--- certified/branches/13.1/include/asterisk/res_pjsip_session.h (original)
+++ certified/branches/13.1/include/asterisk/res_pjsip_session.h Fri Dec 19 14:42:56 2014
@@ -434,6 +434,14 @@
struct ast_format_cap *req_caps);
/*!
+ * \brief Terminate a session and, if possible, send the provided response code
+ *
+ * \param session The session to terminate
+ * \param response The response code to use for termination if possible
+ */
+void ast_sip_session_terminate(struct ast_sip_session *session, int response);
+
+/*!
* \brief Defer local termination of a session until remote side terminates, or an amount of time passes
*
* \param session The session to defer termination on
Modified: certified/branches/13.1/res/res_pjsip_session.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_pjsip_session.c?view=diff&rev=429864&r1=429863&r2=429864
==============================================================================
--- certified/branches/13.1/res/res_pjsip_session.c (original)
+++ certified/branches/13.1/res/res_pjsip_session.c Fri Dec 19 14:42:56 2014
@@ -528,6 +528,8 @@
} else if (!strcmp(delay->method, "UPDATE")) {
ast_sip_session_refresh(session, delay->on_request_creation,
delay->on_sdp_creation, delay->on_response, AST_SIP_SESSION_REFRESH_METHOD_UPDATE, delay->generate_new_sdp);
+ } else if (!strcmp(delay->method, "BYE")) {
+ ast_sip_session_terminate(session, 0);
} else {
ast_log(LOG_WARNING, "Unexpected delayed %s request with no existing request structure\n", delay->method);
return -1;
@@ -1290,6 +1292,38 @@
ao2_ref(session, +1);
return session;
+}
+
+void ast_sip_session_terminate(struct ast_sip_session *session, int response)
+{
+ pj_status_t status;
+ pjsip_tx_data *packet = NULL;
+
+ if (session->defer_terminate) {
+ return;
+ }
+
+ if (!response) {
+ response = 603;
+ }
+
+ if ((session->inv_session->state == PJSIP_INV_STATE_CONFIRMED) && session->inv_session->invite_tsx) {
+ ast_debug(3, "Delaying sending BYE to %s because of outstanding transaction...\n",
+ 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
+ * actually need to store the response code for when it happens.
+ */
+ delay_request(session, NULL, NULL, NULL, 0, "BYE");
+ } else if (session->inv_session->state == PJSIP_INV_STATE_NULL) {
+ pjsip_inv_terminate(session->inv_session, response, PJ_TRUE);
+ } else if (((status = pjsip_inv_end_session(session->inv_session, response, 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);
+ }
+ }
}
static int session_termination_task(void *data)
Modified: certified/branches/13.1/res/res_pjsip_session.exports.in
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_pjsip_session.exports.in?view=diff&rev=429864&r1=429863&r2=429864
==============================================================================
--- certified/branches/13.1/res/res_pjsip_session.exports.in (original)
+++ certified/branches/13.1/res/res_pjsip_session.exports.in Fri Dec 19 14:42:56 2014
@@ -1,5 +1,6 @@
{
global:
+ LINKER_SYMBOL_PREFIXast_sip_session_terminate;
LINKER_SYMBOL_PREFIXast_sip_session_defer_termination;
LINKER_SYMBOL_PREFIXast_sip_session_register_sdp_handler;
LINKER_SYMBOL_PREFIXast_sip_session_unregister_sdp_handler;
More information about the asterisk-commits
mailing list