[Asterisk-code-review] res pjsip: Send a 503 response when overload state if reliab... (asterisk[16])

Kevin Harwell asteriskteam at digium.com
Thu Nov 8 13:05:47 CST 2018


Kevin Harwell has submitted this change and it was merged. ( https://gerrit.asterisk.org/10595 )

Change subject: res_pjsip: Send a 503 response when overload state if reliable transport.
......................................................................

res_pjsip: Send a 503 response when overload state if reliable transport.

When Asterisk's taskprocessors get overloaded we need to reduce the work
load. res_pjsip currently ignores new SIP requests and relies on SIP
retransmissions in the hope that the overload condition will clear soon
enough to handle the retransmitted SIP request.
This change adds the following code after ast_taskprocessor_alert_get()
has returned TRUE:
1- identifies transport type. If non-udp then send a 503 response
2- if transport type is udp/udp6 then ignore, as before.

Change-Id: I1c230b40d43a254ea0f226b7acf9ee480a5d3836
---
M res/res_pjsip/pjsip_distributor.c
1 file changed, 15 insertions(+), 5 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, but someone else must approve
  Matthew Fredrickson: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved; Approved for Submit



diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c
index 4bd3b00..d356e37 100644
--- a/res/res_pjsip/pjsip_distributor.c
+++ b/res/res_pjsip/pjsip_distributor.c
@@ -540,12 +540,22 @@
 			 * we are being overloaded and need to defer adding new work to
 			 * the system.  To defer the work we will ignore the request and
 			 * rely on the peer's transport layer to retransmit the message.
-			 * We usually work off the overload within a few seconds.  The
-			 * alternative is to send back a 503 response to these requests
-			 * and be done with it.
+			 * We usually work off the overload within a few seconds.
+			 * If transport is non-UDP we send a 503 response instead.
 			 */
-			ast_debug(3, "Taskprocessor overload alert: Ignoring '%s'.\n",
-				pjsip_rx_data_get_info(rdata));
+			switch (rdata->tp_info.transport->key.type) {
+			case PJSIP_TRANSPORT_UDP6:
+			case PJSIP_TRANSPORT_UDP:
+				ast_debug(3, "Taskprocessor overload alert: Ignoring '%s'.\n",
+					pjsip_rx_data_get_info(rdata));
+				break;
+			default:
+				ast_debug(3, "Taskprocessor overload on non-udp transport. Received:'%s'. "
+					"Responding with a 503.\n", pjsip_rx_data_get_info(rdata));
+				pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata,
+					PJSIP_SC_SERVICE_UNAVAILABLE, NULL, NULL, NULL);
+				break;
+			}
 			ao2_cleanup(dist);
 			return PJ_TRUE;
 		}

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-MessageType: merged
Gerrit-Change-Id: I1c230b40d43a254ea0f226b7acf9ee480a5d3836
Gerrit-Change-Number: 10595
Gerrit-PatchSet: 3
Gerrit-Owner: Chris Savinovich <csavinovich at digium.com>
Gerrit-Reviewer: Chris Savinovich <csavinovich at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181108/8d0fece7/attachment-0001.html>


More information about the asterisk-code-review mailing list