[Asterisk-code-review] chan_pjsip: Stop queueing control frames twice on outgoing channels (asterisk[16])

Ivan Poddubny asteriskteam at digium.com
Wed Jan 6 03:03:30 CST 2021


Ivan Poddubny has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15304 )


Change subject: chan_pjsip: Stop queueing control frames twice on outgoing channels
......................................................................

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
---
M channels/chan_pjsip.c
1 file changed, 17 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/04/15304/1

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 649dd36..1e54e84 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -137,6 +137,7 @@
 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 @@
 	.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_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,
 };
 
@@ -3080,7 +3082,7 @@
 };
 
 /*! \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;
@@ -3106,6 +3108,19 @@
 	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));

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15304
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I0a1874be5bb5ed12d572d17c7f80de6e5e542940
Gerrit-Change-Number: 15304
Gerrit-PatchSet: 1
Gerrit-Owner: Ivan Poddubny <ivan.poddubny at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210106/76628caf/attachment-0001.html>


More information about the asterisk-code-review mailing list