summaryrefslogtreecommitdiff
path: root/channels/chan_pjsip.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-09-02 20:29:58 +0000
committerMark Michelson <mmichelson@digium.com>2014-09-02 20:29:58 +0000
commit1b64f353f1cfb98671e95726160987bd69a2f3ae (patch)
tree5d1660e40482d1f0ed8d0695e2824db57f8e74f9 /channels/chan_pjsip.c
parent897cbf6a4f4123a3c7462da2b373e96d784b02be (diff)
Resolve race condition where channels enter dialplan application before media has been negotiated.
Testsuite tests will occasionally fail because on reception of a 200 OK SIP response, an AST_CONTROL_ANSWER frame is queued prior to when media has finished being negotiated. This is because session supplements are called into before PJSIP's inv_session code has told us that media has been updated. Sometimes the queued answer frame is handled by the PBX thread before the ensuing media negotiations occur, causing a test failure. As it turns out, there is another place that session supplements could be called into, which is after media has finished getting negotiated. What this commit introduces is a means for session supplements to indicate when they wish to be called into when handling an incoming SIP response. By default, all session supplements will be run at the same point that they were prior to this commit. However, session supplements may indicate that they wish to be handled earlier than normal on redirects, or they may indicate they wish to be handled after media has been negotiated. In this changeset, two session supplements have been updated to indicate a preference for when they should be run: res_pjsip_diversion executes before handling redirection in order to get information from the Diversion header, and chan_pjsip now handles responses to INVITEs after media negotiation to fix the race condition mentioned previously. ASTERISK-24212 #close Reported by Matt Jordan Review: https://reviewboard.asterisk.org/r/3930 ........ Merged revisions 422536 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 422542 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422543 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_pjsip.c')
-rw-r--r--channels/chan_pjsip.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 7680aec54..342eabb21 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -145,6 +145,8 @@ static struct ast_sip_session_supplement chan_pjsip_supplement = {
.session_end = chan_pjsip_session_end,
.incoming_request = chan_pjsip_incoming_request,
.incoming_response = chan_pjsip_incoming_response,
+ /* It is important that this supplement runs after media has been negotiated */
+ .response_priority = AST_SIP_SESSION_AFTER_MEDIA,
};
static int chan_pjsip_incoming_ack(struct ast_sip_session *session, struct pjsip_rx_data *rdata);
@@ -2029,6 +2031,11 @@ static int call_pickup_incoming_request(struct ast_sip_session *session, pjsip_r
struct ast_features_pickup_config *pickup_cfg = ast_get_chan_features_pickup_config(session->channel);
struct ast_channel *chan;
+ /* We don't care about reinvites */
+ if (session->inv_session->state >= PJSIP_INV_STATE_CONFIRMED) {
+ return 0;
+ }
+
if (!pickup_cfg) {
ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension.\n");
return 0;
@@ -2071,6 +2078,11 @@ static int pbx_start_incoming_request(struct ast_sip_session *session, pjsip_rx_
{
int res;
+ /* We don't care about reinvites */
+ if (session->inv_session->state >= PJSIP_INV_STATE_CONFIRMED) {
+ return 0;
+ }
+
res = ast_pbx_start(session->channel);
switch (res) {