<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18223">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pbx.c: Warn if there are too many includes in a context.<br><br>The PBX core uses the stack when it comes to includes, which<br>means that a context can only contain strictly fewer than<br>AST_PBX_MAX_STACK includes. If this is exceeded, then warnings<br>will be emitted for each number of includes beyond this if<br>searching for an extension in the including context, and if<br>the extension's inclusion is beyond the stack size, it will<br>simply not be found.<br><br>To address this, we now check if there are too many includes<br>in a context when the dialplan is reloaded so that if there<br>is an issue, the user is aware of at "compile time" as opposed<br>to "run time" only. Secondly, more details are printed out<br>when this message is encountered so it's clear what has happened.<br><br>ASTERISK-26719<br><br>Change-Id: Ia3700452e75a7af3391b3e82ee69f06a669f8958<br>---<br>M main/pbx.c<br>1 file changed, 8 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/pbx.c b/main/pbx.c</span><br><span>index 07cf8e7..00c653f 100644</span><br><span>--- a/main/pbx.c</span><br><span>+++ b/main/pbx.c</span><br><span>@@ -2506,7 +2506,7 @@</span><br><span>          q->data = NULL;</span><br><span>           q->foundcontext = NULL;</span><br><span>   } else if (q->stacklen >= AST_PBX_MAX_STACK) {</span><br><span style="color: hsl(0, 100%, 40%);">-            ast_log(LOG_WARNING, "Maximum PBX stack exceeded\n");</span><br><span style="color: hsl(120, 100%, 40%);">+               ast_log(LOG_WARNING, "Maximum PBX stack (%d) exceeded. Too many includes?\n", AST_PBX_MAX_STACK);</span><br><span>          return NULL;</span><br><span>         }</span><br><span> </span><br><span>@@ -8771,8 +8771,14 @@</span><br><span> {</span><br><span>  int idx;</span><br><span>     int res = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+  int includecount = ast_context_includes_count(con);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- for (idx = 0; idx < ast_context_includes_count(con); idx++) {</span><br><span style="color: hsl(120, 100%, 40%);">+      if (includecount >= AST_PBX_MAX_STACK) {</span><br><span style="color: hsl(120, 100%, 40%);">+           ast_log(LOG_WARNING, "Context %s contains too many includes (%d). Maximum is %d.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                        ast_get_context_name(con), includecount, AST_PBX_MAX_STACK);</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   for (idx = 0; idx < includecount; idx++) {</span><br><span>                const struct ast_include *inc = ast_context_includes_get(con, idx);</span><br><span> </span><br><span>              if (ast_context_find(include_rname(inc))) {</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18223">change 18223</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/c/asterisk/+/18223"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Ia3700452e75a7af3391b3e82ee69f06a669f8958 </div>
<div style="display:none"> Gerrit-Change-Number: 18223 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-CC: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>