Commit 134d2e729d for asterisk.org
commit 134d2e729df8ff2f372362b2f2b5bdcaad8f783b
Author: Ivan Poddubnyi <ivan.poddubny@gmail.com>
Date: Thu Dec 31 12:53:34 2020 +0100
chan_pjsip: Stop queueing control frames twice on outgoing channels
The fix for ASTERISK-27902 made chan_pjsip process SIP responses twice.
This resulted in extra noise in logs (for example, "is making progress"
and "is ringing" get logged twice by app_dial), as well as in noise in
signalling: one incoming 183 Session Progress results in 2 outgoing 183-s.
This change splits the response handler into 2 functions:
- one for updating HANGUPCAUSE, which is still called twice,
- another that does the rest, which is called only once as before.
ASTERISK-28016
Reported-by: Alex Hermann
ASTERISK-28549
Reported-by: Gant Liu
ASTERISK-28185
Reported-by: Julien
Change-Id: I0a1874be5bb5ed12d572d17c7f80de6e5e542940
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index bb04d7363d..46fa32775c 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -137,6 +137,7 @@ static void chan_pjsip_session_begin(struct ast_sip_session *session);
static void chan_pjsip_session_end(struct ast_sip_session *session);
static int chan_pjsip_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata);
static void chan_pjsip_incoming_response(struct ast_sip_session *session, struct pjsip_rx_data *rdata);
+static void chan_pjsip_incoming_response_update_cause(struct ast_sip_session *session, struct pjsip_rx_data *rdata);
/*! \brief SIP session supplement structure */
static struct ast_sip_session_supplement chan_pjsip_supplement = {
@@ -145,6 +146,7 @@ static struct ast_sip_session_supplement chan_pjsip_supplement = {
.session_begin = chan_pjsip_session_begin,
.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,
};
@@ -153,7 +155,7 @@ static struct ast_sip_session_supplement chan_pjsip_supplement = {
static struct ast_sip_session_supplement chan_pjsip_supplement_response = {
.method = "INVITE",
.priority = AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL,
- .incoming_response = chan_pjsip_incoming_response,
+ .incoming_response = chan_pjsip_incoming_response_update_cause,
.response_priority = AST_SIP_SESSION_BEFORE_MEDIA | AST_SIP_SESSION_AFTER_MEDIA,
};
@@ -3125,7 +3127,7 @@ static struct ast_sip_session_supplement pbx_start_supplement = {
};
/*! \brief Function called when a response is received on the session */
-static void chan_pjsip_incoming_response(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
+static void chan_pjsip_incoming_response_update_cause(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
{
struct pjsip_status_line status = rdata->msg_info.msg->line.status;
struct ast_control_pvt_cause_code *cause_code;
@@ -3151,6 +3153,19 @@ static void chan_pjsip_incoming_response(struct ast_sip_session *session, struct
ast_queue_control_data(session->channel, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
ast_channel_hangupcause_hash_set(session->channel, cause_code, data_size);
+ SCOPE_EXIT_RTN("%s\n", ast_sip_session_get_name(session));
+}
+
+/*! \brief Function called when a response is received on the session */
+static void chan_pjsip_incoming_response(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
+{
+ struct pjsip_status_line status = rdata->msg_info.msg->line.status;
+ SCOPE_ENTER(3, "%s: Status: %d\n", ast_sip_session_get_name(session), status.code);
+
+ if (!session->channel) {
+ SCOPE_EXIT_RTN("%s: No channel\n", ast_sip_session_get_name(session));
+ }
+
switch (status.code) {
case 180:
ast_trace(-1, "%s: Queueing RINGING\n", ast_sip_session_get_name(session));