<p>Kevin Harwell <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10596">View Change</a></p><div style="white-space:pre-wrap">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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip: Send a 503 response when overload state if reliable transport.<br><br>When Asterisk's taskprocessors get overloaded we need to reduce the work<br>load. res_pjsip currently ignores new SIP requests and relies on SIP<br>retransmissions in the hope that the overload condition will clear soon<br>enough to handle the retransmitted SIP request.<br>This change adds the following code after ast_taskprocessor_alert_get()<br>has returned TRUE:<br>1- identifies transport type. If non-udp then send a 503 response<br>2- if transport type is udp/udp6 then ignore, as before.<br><br>Change-Id: I1c230b40d43a254ea0f226b7acf9ee480a5d3836<br>---<br>M res/res_pjsip/pjsip_distributor.c<br>1 file changed, 15 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c</span><br><span>index 4bd3b00..d356e37 100644</span><br><span>--- a/res/res_pjsip/pjsip_distributor.c</span><br><span>+++ b/res/res_pjsip/pjsip_distributor.c</span><br><span>@@ -540,12 +540,22 @@</span><br><span>                     * we are being overloaded and need to defer adding new work to</span><br><span>                       * the system.  To defer the work we will ignore the request and</span><br><span>                      * rely on the peer's transport layer to retransmit the message.</span><br><span style="color: hsl(0, 100%, 40%);">-                     * We usually work off the overload within a few seconds.  The</span><br><span style="color: hsl(0, 100%, 40%);">-                   * alternative is to send back a 503 response to these requests</span><br><span style="color: hsl(0, 100%, 40%);">-                  * and be done with it.</span><br><span style="color: hsl(120, 100%, 40%);">+                        * We usually work off the overload within a few seconds.</span><br><span style="color: hsl(120, 100%, 40%);">+                      * If transport is non-UDP we send a 503 response instead.</span><br><span>                    */</span><br><span style="color: hsl(0, 100%, 40%);">-                     ast_debug(3, "Taskprocessor overload alert: Ignoring '%s'.\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                                pjsip_rx_data_get_info(rdata));</span><br><span style="color: hsl(120, 100%, 40%);">+                       switch (rdata->tp_info.transport->key.type) {</span><br><span style="color: hsl(120, 100%, 40%);">+                   case PJSIP_TRANSPORT_UDP6:</span><br><span style="color: hsl(120, 100%, 40%);">+                    case PJSIP_TRANSPORT_UDP:</span><br><span style="color: hsl(120, 100%, 40%);">+                             ast_debug(3, "Taskprocessor overload alert: Ignoring '%s'.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                      pjsip_rx_data_get_info(rdata));</span><br><span style="color: hsl(120, 100%, 40%);">+                               break;</span><br><span style="color: hsl(120, 100%, 40%);">+                        default:</span><br><span style="color: hsl(120, 100%, 40%);">+                              ast_debug(3, "Taskprocessor overload on non-udp transport. Received:'%s'. "</span><br><span style="color: hsl(120, 100%, 40%);">+                                 "Responding with a 503.\n", pjsip_rx_data_get_info(rdata));</span><br><span style="color: hsl(120, 100%, 40%);">+                         pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata,</span><br><span style="color: hsl(120, 100%, 40%);">+                                    PJSIP_SC_SERVICE_UNAVAILABLE, NULL, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+                              break;</span><br><span style="color: hsl(120, 100%, 40%);">+                        }</span><br><span>                    ao2_cleanup(dist);</span><br><span>                   return PJ_TRUE;</span><br><span>              }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10596">change 10596</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10596"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I1c230b40d43a254ea0f226b7acf9ee480a5d3836 </div>
<div style="display:none"> Gerrit-Change-Number: 10596 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Chris Savinovich <csavinovich@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Matthew Fredrickson <creslin@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>