<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/10447">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">loader: Perform chained starts when missing dependencies are started.<br><br>After a module is manually loaded recheck the full list of declined<br>modules. Determine if any modules that were previously missing<br>dependencies can now be started.<br><br>This is only effective for modules which are loaded but declined for<br>non-started dependencies. This has no effect on modules which<br>previously could not be dlopen'ed due to unresolved symbols, those<br>modules still must be manually loaded.<br><br>Change-Id: I1cfe77a550a036b549ff5c47c05f69eead61f5e3<br>---<br>M main/loader.c<br>1 file changed, 48 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/47/10447/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/loader.c b/main/loader.c</span><br><span>index 865346f..deb9aef 100644</span><br><span>--- a/main/loader.c</span><br><span>+++ b/main/loader.c</span><br><span>@@ -207,6 +207,8 @@</span><br><span> unsigned int running:1;</span><br><span> /*! The module has declined to start. */</span><br><span> unsigned int declined:1;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! The module is missing a dependency. */</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int missingdep:1;</span><br><span> /*! This module is being held open until it's time to shutdown. */</span><br><span> unsigned int keepuntilshutdown:1;</span><br><span> /*! The module is built-in. */</span><br><span>@@ -1552,6 +1554,8 @@</span><br><span> struct module_vector missing;</span><br><span> int i;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* We only get here if the module is being manually loaded. */</span><br><span style="color: hsl(120, 100%, 40%);">+ mod->flags.missingdep = mod->flags.declined = 1;</span><br><span> AST_VECTOR_INIT(&missing, 0);</span><br><span> if (module_deps_missing_recursive(mod, &missing)) {</span><br><span> module_load_error("%s has one or more unknown dependencies.\n", mod->info->name);</span><br><span>@@ -1675,10 +1679,51 @@</span><br><span> int ast_load_resource(const char *resource_name)</span><br><span> {</span><br><span> int res;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> AST_DLLIST_LOCK(&module_list);</span><br><span> res = load_resource(resource_name, 0, NULL, 0, 0);</span><br><span style="color: hsl(0, 100%, 40%);">- if (!res) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (res == AST_MODULE_LOAD_SUCCESS) {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct module_vector missingdeps;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_module *cur;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_test_suite_event_notify("MODULE_LOAD", "Message: %s", resource_name);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_VECTOR_INIT(&missingdeps, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_DLLIST_TRAVERSE(&module_list, cur, entry) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (cur->flags.declined && cur->flags.missingdep) {</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_VECTOR_APPEND(&missingdeps, cur);</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%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ while (AST_VECTOR_SIZE(&missingdeps)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ int didwork = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ int i = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ while (i < AST_VECTOR_SIZE(&missingdeps)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ cur = AST_VECTOR_GET(&missingdeps, i);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!module_deps_reference(cur, NULL)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ cur->flags.declined = cur->flags.missingdep = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ res = start_resource(cur);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (res == AST_MODULE_LOAD_SUCCESS) {</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_VECTOR_REMOVE(&missingdeps, i, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_test_suite_event_notify("MODULE_LOAD", "Message: %s",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_module_name(cur));</span><br><span style="color: hsl(120, 100%, 40%);">+ didwork = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</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%);">+ i++;</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%);">+ if (!didwork) {</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</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%);">+ AST_VECTOR_FREE(&missingdeps);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Report success for load of resource_name even if this cleared the</span><br><span style="color: hsl(120, 100%, 40%);">+ * missingdep of another module which still failed to start. */</span><br><span style="color: hsl(120, 100%, 40%);">+ res = AST_MODULE_LOAD_SUCCESS;</span><br><span> }</span><br><span> AST_DLLIST_UNLOCK(&module_list);</span><br><span> </span><br><span>@@ -1801,6 +1846,7 @@</span><br><span> </span><br><span> if (AST_VECTOR_GET_CMP(&missingdeps, mod, AST_VECTOR_ELEM_DEFAULT_CMP)) {</span><br><span> dep->flags.declined = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ dep->flags.missingdep = 1;</span><br><span> if (dep->flags.required) {</span><br><span> module_load_error("Cannot load required module %s that depends on %s\n",</span><br><span> ast_module_name(dep), ast_module_name(mod));</span><br><span>@@ -1932,6 +1978,7 @@</span><br><span> module_load_error("Failed to load %s due to dependencies: %s.\n",</span><br><span> ast_module_name(mod),</span><br><span> printmissing ? ast_str_buffer(printmissing) : "allocation failure creating list");</span><br><span style="color: hsl(120, 100%, 40%);">+ mod->flags.missingdep = 1;</span><br><span> res = resource_list_recursive_decline(resources, mod, &printmissing);</span><br><span> </span><br><span> AST_VECTOR_RESET(&missingdeps, AST_VECTOR_ELEM_CLEANUP_NOOP);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10447">change 10447</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/10447"/><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: I1cfe77a550a036b549ff5c47c05f69eead61f5e3 </div>
<div style="display:none"> Gerrit-Change-Number: 10447 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>