[asterisk-commits] file: branch 12 r419764 - /branches/12/res/res_pjsip_session.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 29 05:55:35 CDT 2014
Author: file
Date: Tue Jul 29 05:52:25 2014
New Revision: 419764
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=419764
Log:
res_pjsip_session: Fix race condition where redirecting information may not be set.
Since the PJSIP INVITE session module is invoked before any session supplements it was
possible for it to handle a redirect before the res_pjsip_diversion module interpreted
and set redirecting information on the channel. This would cause the redirecting
information to get lost.
This patch ensures that session supplements are *always* invoked before a redirect occurs
by explicitly calling them in the redirect handler.
Review: https://reviewboard.asterisk.org/r/3850/
Modified:
branches/12/res/res_pjsip_session.c
Modified: branches/12/res/res_pjsip_session.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip_session.c?view=diff&rev=419764&r1=419763&r2=419764
==============================================================================
--- branches/12/res/res_pjsip_session.c (original)
+++ branches/12/res/res_pjsip_session.c Tue Jul 29 05:52:25 2014
@@ -55,9 +55,9 @@
static const pj_str_t *hostname;
/* Some forward declarations */
-static void handle_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata);
-static void handle_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata);
-static int handle_incoming(struct ast_sip_session *session, pjsip_rx_data *rdata);
+static void handle_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata, pjsip_event_id_e type);
+static void handle_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata, pjsip_event_id_e type);
+static int handle_incoming(struct ast_sip_session *session, pjsip_rx_data *rdata, pjsip_event_id_e type);
static void handle_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata);
static void handle_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata);
static void handle_outgoing(struct ast_sip_session *session, pjsip_tx_data *tdata);
@@ -1561,7 +1561,7 @@
}
ast_sip_session_send_response(invite->session, tdata);
- handle_incoming_request(invite->session, invite->rdata);
+ handle_incoming_request(invite->session, invite->rdata, PJSIP_EVENT_RX_MSG);
return 0;
}
@@ -1772,7 +1772,7 @@
#define print_debug_details(inv, tsx, e) __print_debug_details(__PRETTY_FUNCTION__, (inv), (tsx), (e))
-static void handle_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
+static void handle_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata, pjsip_event_id_e type)
{
struct ast_sip_session_supplement *supplement;
struct pjsip_request_line req = rdata->msg_info.msg->line.req;
@@ -1787,10 +1787,15 @@
}
}
-static void handle_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata)
+static void handle_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata, pjsip_event_id_e type)
{
struct ast_sip_session_supplement *supplement;
struct pjsip_status_line status = rdata->msg_info.msg->line.status;
+
+ /* Squash all redirect transaction related responses as the supplements have already been invoked */
+ if (type == PJSIP_EVENT_TSX_STATE && PJSIP_IS_STATUS_IN_CLASS(status.code, 300)) {
+ return;
+ }
ast_debug(3, "Response is %d %.*s\n", status.code, (int) pj_strlen(&status.reason),
pj_strbuf(&status.reason));
@@ -1802,15 +1807,15 @@
}
}
-static int handle_incoming(struct ast_sip_session *session, pjsip_rx_data *rdata)
+static int handle_incoming(struct ast_sip_session *session, pjsip_rx_data *rdata, pjsip_event_id_e type)
{
ast_debug(3, "Received %s\n", rdata->msg_info.msg->type == PJSIP_REQUEST_MSG ?
"request" : "response");
if (rdata->msg_info.msg->type == PJSIP_REQUEST_MSG) {
- handle_incoming_request(session, rdata);
+ handle_incoming_request(session, rdata, type);
} else {
- handle_incoming_response(session, rdata);
+ handle_incoming_response(session, rdata, type);
}
return 0;
@@ -1900,7 +1905,7 @@
handle_outgoing(session, e->body.tx_msg.tdata);
break;
case PJSIP_EVENT_RX_MSG:
- handle_incoming(session, e->body.rx_msg.rdata);
+ handle_incoming(session, e->body.rx_msg.rdata, type);
break;
case PJSIP_EVENT_TSX_STATE:
ast_debug(3, "Source of transaction state change is %s\n", pjsip_event_str(e->body.tsx_state.type));
@@ -1910,7 +1915,7 @@
handle_outgoing(session, e->body.tsx_state.src.tdata);
break;
case PJSIP_EVENT_RX_MSG:
- handle_incoming(session, e->body.tsx_state.src.rdata);
+ handle_incoming(session, e->body.tsx_state.src.rdata, type);
break;
case PJSIP_EVENT_TRANSPORT_ERROR:
case PJSIP_EVENT_TIMER:
@@ -1993,7 +1998,7 @@
}
} else {
if (tsx->role == PJSIP_ROLE_UAS && tsx->state == PJSIP_TSX_STATE_TRYING) {
- handle_incoming_request(session, e->body.tsx_state.src.rdata);
+ handle_incoming_request(session, e->body.tsx_state.src.rdata, PJSIP_EVENT_TSX_STATE);
}
}
if ((cb = ast_sip_mod_data_get(tsx->mod_data, session_module.id,
@@ -2154,6 +2159,8 @@
if (!PJSIP_URI_SCHEME_IS_SIP(target) && !PJSIP_URI_SCHEME_IS_SIPS(target)) {
return PJSIP_REDIRECT_STOP;
}
+
+ handle_incoming(session, e->body.rx_msg.rdata, PJSIP_EVENT_RX_MSG);
uri = pjsip_uri_get_uri(target);
More information about the asterisk-commits
mailing list