<p>Joshua Colp has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14573">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">menuselect: Resolve infinite loop in dependency scenario.<br><br>Given a scenario where a module has a dependency on both<br>an external library and a module if the external library was<br>available and the module was not an infinite loop would<br>occur. This happened due to the code changing the dependecy<br>status to no failure on each dependency checking loop<br>iteration, resulting in the code thinking that it had<br>gone from no failure to failure each time triggering another<br>dependency check.<br><br>This change makes it so that the old dependency status is<br>preserved throughout the dependency checking allowing it to<br>determine that after the first iteration the dependency<br>status does not transition from no failure to failure.<br><br>ASTERISK-28930<br><br>Change-Id: Iea06d45d9fd6d8bfd068882a0bb7e23a53ec3e84<br>---<br>M menuselect/menuselect.c<br>M menuselect/menuselect.h<br>2 files changed, 8 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/73/14573/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/menuselect/menuselect.c b/menuselect/menuselect.c</span><br><span>index 83f6098..a595ce8 100644</span><br><span>--- a/menuselect/menuselect.c</span><br><span>+++ b/menuselect/menuselect.c</span><br><span>@@ -630,14 +630,14 @@</span><br><span>         struct member *mem;</span><br><span>  struct reference *dep;</span><br><span>       struct dep_file *dep_file;</span><br><span style="color: hsl(0, 100%, 40%);">-      unsigned int changed, old_failure;</span><br><span style="color: hsl(120, 100%, 40%);">+    unsigned int changed;</span><br><span> </span><br><span>    AST_LIST_TRAVERSE(&categories, cat, list) {</span><br><span>              AST_LIST_TRAVERSE(&cat->members, mem, list) {</span><br><span>                         if (mem->is_separator) {</span><br><span>                          continue;</span><br><span>                    }</span><br><span style="color: hsl(0, 100%, 40%);">-                       old_failure = mem->depsfailed;</span><br><span style="color: hsl(120, 100%, 40%);">+                     mem->depsfailedold = mem->depsfailed;</span><br><span>                  AST_LIST_TRAVERSE(&mem->deps, dep, list) {</span><br><span>                            if (dep->member)</span><br><span>                                  continue;</span><br><span>@@ -655,7 +655,7 @@</span><br><span>                                      break; /* This dependency is not met, so we can stop now */</span><br><span>                          }</span><br><span>                    }</span><br><span style="color: hsl(0, 100%, 40%);">-                       if (old_failure == SOFT_FAILURE && mem->depsfailed != HARD_FAILURE)</span><br><span style="color: hsl(120, 100%, 40%);">+                        if (mem->depsfailedold == SOFT_FAILURE && mem->depsfailed != HARD_FAILURE)</span><br><span>                             mem->depsfailed = SOFT_FAILURE;</span><br><span>           }</span><br><span>    }</span><br><span>@@ -673,8 +673,6 @@</span><br><span>                                      continue;</span><br><span>                            }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                           old_failure = mem->depsfailed;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>                            if (mem->depsfailed == HARD_FAILURE)</span><br><span>                                      continue;</span><br><span> </span><br><span>@@ -693,7 +691,7 @@</span><br><span>                                  }</span><br><span>                            }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                           if (mem->depsfailed != old_failure) {</span><br><span style="color: hsl(120, 100%, 40%);">+                              if (mem->depsfailed != mem->depsfailedold) {</span><br><span>                                   if ((mem->depsfailed == NO_FAILURE) && mem->was_defaulted) {</span><br><span>                                           mem->enabled = !strcasecmp(mem->defaultenabled, "yes");</span><br><span>                                              print_debug("Just set %s enabled to %d\n", mem->name, mem->enabled);</span><br><span>@@ -702,6 +700,8 @@</span><br><span>                                           print_debug("Just set %s enabled to %d\n", mem->name, mem->enabled);</span><br><span>                                         }</span><br><span>                                    changed = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+                                  /* We need to update the old failed deps for the next loop of this */</span><br><span style="color: hsl(120, 100%, 40%);">+                                 mem->depsfailedold = mem->depsfailed;</span><br><span>                                  break; /* This dependency is not met, so we can stop now */</span><br><span>                          }</span><br><span>                    }</span><br><span>diff --git a/menuselect/menuselect.h b/menuselect/menuselect.h</span><br><span>index 78ae8ef..d41859e 100644</span><br><span>--- a/menuselect/menuselect.h</span><br><span>+++ b/menuselect/menuselect.h</span><br><span>@@ -78,6 +78,8 @@</span><br><span>       unsigned int was_enabled:1;</span><br><span>  /*! This module has failed dependencies */</span><br><span>   unsigned int depsfailed:2;</span><br><span style="color: hsl(120, 100%, 40%);">+    /*! Previous failed dependencies when calculating */</span><br><span style="color: hsl(120, 100%, 40%);">+  unsigned int depsfailedold:2;</span><br><span>        /*! This module has failed conflicts */</span><br><span>      unsigned int conflictsfailed:2;</span><br><span>      /*! This module's 'enabled' flag was changed by a default only */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14573">change 14573</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/+/14573"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Iea06d45d9fd6d8bfd068882a0bb7e23a53ec3e84 </div>
<div style="display:none"> Gerrit-Change-Number: 14573 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>