[Asterisk-code-review] res pjsip session: Don't invoke session supplements twice fo... (asterisk[master])
Mark Michelson
asteriskteam at digium.com
Fri Aug 28 12:29:23 CDT 2015
Mark Michelson has submitted this change and it was merged.
Change subject: res_pjsip_session: Don't invoke session supplements twice for BYE requests.
......................................................................
res_pjsip_session: Don't invoke session supplements twice for BYE requests.
When a BYE request is received the PJSIP invite session implementation
creates and sends a 200 OK response before we are aware of it. This
causes the INVITE session state callback to be called into and ultimately
the session supplements run on the BYE request. Once this response has
been sent the normal transaction state callback is invoked which
invokes the session supplements on the BYE request again. This can
be problematic in particular with res_pjsip_rfc3326 as it may
attempt to update the hangup cause code on the channel while it is
in the process of being hung up.
This change makes it so the session supplements are only invoked
once by the INVITE session state callback.
ASTERISK-25318 #close
Change-Id: I69c17df55ccbb61ef779ac38cc8c6b411376c19a
---
M res/res_pjsip_session.c
1 file changed, 10 insertions(+), 2 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Mark Michelson: Looks good to me, approved
Anonymous Coward #1000019: Verified
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index a3c0dfc..8017464 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -2422,8 +2422,16 @@
break;
case PJSIP_EVENT_RX_MSG:
cb = ast_sip_mod_data_get(tsx->mod_data, session_module.id, MOD_DATA_ON_RESPONSE);
- handle_incoming(session, e->body.tsx_state.src.rdata, e->type,
- AST_SIP_SESSION_AFTER_MEDIA);
+ /* As the PJSIP invite session implementation responds with a 200 OK before we have a
+ * chance to be invoked session supplements for BYE requests actually end up executing
+ * in the invite session state callback as well. To prevent session supplements from
+ * running on the BYE request again we explicitly squash invocation of them here.
+ */
+ if ((e->body.tsx_state.src.rdata->msg_info.msg->type != PJSIP_REQUEST_MSG) ||
+ (tsx->method.id != PJSIP_BYE_METHOD)) {
+ handle_incoming(session, e->body.tsx_state.src.rdata, e->type,
+ AST_SIP_SESSION_AFTER_MEDIA);
+ }
if (tsx->method.id == PJSIP_INVITE_METHOD) {
if (tsx->role == PJSIP_ROLE_UAC) {
if (tsx->state == PJSIP_TSX_STATE_COMPLETED) {
--
To view, visit https://gerrit.asterisk.org/1153
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I69c17df55ccbb61ef779ac38cc8c6b411376c19a
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
More information about the asterisk-code-review
mailing list