<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8048">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">loader: Correct overly strict startup checks.<br><br>The code which handled loading modules had too many situations which<br>would result in halting Asterisk startup.  Treat most errors as declines<br>instead of failures.  The exception is when the module load function<br>returns AST_MODULE_LOAD_FAILURE or an invalid code.<br><br>Clear the missingdeps vector when appropriate to ensure the next loop<br>starts clean.<br><br>ASTERISK-27620<br><br>Change-Id: I45547d9641fd45bd86d80250224417625631ad84<br>---<br>M main/loader.c<br>1 file changed, 19 insertions(+), 13 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/48/8048/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/loader.c b/main/loader.c<br>index da508f3..159014e 100644<br>--- a/main/loader.c<br>+++ b/main/loader.c<br>@@ -1394,7 +1394,7 @@<br>            }<br>             AST_VECTOR_FREE(&missing);<br> <br>-            return AST_MODULE_LOAD_FAILURE;<br>+              return AST_MODULE_LOAD_DECLINE;<br>       }<br> <br>  if (!ast_fully_booted) {<br>@@ -1580,6 +1580,7 @@<br>               struct ast_module *mod = AST_VECTOR_REMOVE(resources, 0, 1);<br>          enum ast_module_load_result lres;<br> <br>+retry_load:<br>            lres = start_resource_attempt(mod, mod_count);<br>                if (lres == AST_MODULE_LOAD_SUCCESS) {<br>                        /* No missing dependencies, successful. */<br>@@ -1598,13 +1599,18 @@<br> <br>                res = module_deps_missing_recursive(mod, &missingdeps);<br>           if (res) {<br>-                   break;<br>+                       AST_VECTOR_RESET(&missingdeps, AST_VECTOR_ELEM_CLEANUP_NOOP);<br>+                    ast_log(LOG_ERROR, "Failed to resolve dependencies for %s\n", ast_module_name(mod));<br>+                       mod->flags.declined = 1;<br>+<br>+                       continue;<br>             }<br> <br>          if (!AST_VECTOR_SIZE(&missingdeps)) {<br>-                    ast_log(LOG_WARNING, "%s isn't missing any dependencies but still didn't start\n",<br>-                         ast_module_name(mod));<br>-                       /* Dependencies were met but the module failed to start. */<br>+                  ast_log(LOG_WARNING, "%s load function returned an invalid result. "<br>+                               "This is a bug in the module.\n", ast_module_name(mod));<br>+                   /* Dependencies were met but the module failed to start and the result<br>+                        * code was not AST_MODULE_LOAD_FAILURE or AST_MODULE_LOAD_DECLINE. */<br>                        res = -1;<br>                     break;<br>                }<br>@@ -1637,17 +1643,17 @@<br>            }<br> <br>          if (AST_VECTOR_SIZE(&missingdeps)) {<br>-                     ast_log(LOG_ERROR, "Failed to load %s due to unfilled dependencies.\n",<br>+                    ast_log(LOG_WARNING, "Failed to load %s due to unfilled dependencies.\n",<br>                           ast_module_name(mod));<br>-                       res = -1;<br>-                    break;<br>+                       mod->flags.declined = 1;<br>+                  AST_VECTOR_RESET(&missingdeps, AST_VECTOR_ELEM_CLEANUP_NOOP);<br>+<br>+                 continue;<br>             }<br> <br>-         res = start_resource_attempt(mod, mod_count);<br>-                if (res) {<br>-                   ast_log(LOG_ERROR, "Failed to load %s: %d\n", ast_module_name(mod), res);<br>-                  break;<br>-               }<br>+            /* If we're here it means that we started with missingdeps and they're all loaded<br>+             * now.  It's impossible to reach this point a second time for the same module. */<br>+               goto retry_load;<br>      }<br> <br>  AST_VECTOR_FREE(&missingdeps);<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8048">change 8048</a>. To unsubscribe, 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/8048"/><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: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I45547d9641fd45bd86d80250224417625631ad84 </div>
<div style="display:none"> Gerrit-Change-Number: 8048 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>