Skip to content
Snippets Groups Projects
Commit a164b7cc authored by Corey Farrell's avatar Corey Farrell
Browse files

loader: Correct overly strict startup checks.

The code which handled loading modules had too many situations which
would result in halting Asterisk startup.  Treat most errors as declines
instead of failures.  The exception is when the module load function
returns AST_MODULE_LOAD_FAILURE or an invalid code.

Clear the missingdeps vector when appropriate to ensure the next loop
starts clean.

ASTERISK-27620

Change-Id: I45547d9641fd45bd86d80250224417625631ad84
parent 7ce34f4e
No related branches found
No related tags found
No related merge requests found
...@@ -1394,7 +1394,7 @@ static enum ast_module_load_result start_resource(struct ast_module *mod) ...@@ -1394,7 +1394,7 @@ static enum ast_module_load_result start_resource(struct ast_module *mod)
} }
AST_VECTOR_FREE(&missing); AST_VECTOR_FREE(&missing);
return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_DECLINE;
} }
if (!ast_fully_booted) { if (!ast_fully_booted) {
...@@ -1580,6 +1580,7 @@ static int start_resource_list(struct module_vector *resources, int *mod_count) ...@@ -1580,6 +1580,7 @@ static int start_resource_list(struct module_vector *resources, int *mod_count)
struct ast_module *mod = AST_VECTOR_REMOVE(resources, 0, 1); struct ast_module *mod = AST_VECTOR_REMOVE(resources, 0, 1);
enum ast_module_load_result lres; enum ast_module_load_result lres;
retry_load:
lres = start_resource_attempt(mod, mod_count); lres = start_resource_attempt(mod, mod_count);
if (lres == AST_MODULE_LOAD_SUCCESS) { if (lres == AST_MODULE_LOAD_SUCCESS) {
/* No missing dependencies, successful. */ /* No missing dependencies, successful. */
...@@ -1598,13 +1599,18 @@ static int start_resource_list(struct module_vector *resources, int *mod_count) ...@@ -1598,13 +1599,18 @@ static int start_resource_list(struct module_vector *resources, int *mod_count)
res = module_deps_missing_recursive(mod, &missingdeps); res = module_deps_missing_recursive(mod, &missingdeps);
if (res) { if (res) {
break; AST_VECTOR_RESET(&missingdeps, AST_VECTOR_ELEM_CLEANUP_NOOP);
ast_log(LOG_ERROR, "Failed to resolve dependencies for %s\n", ast_module_name(mod));
mod->flags.declined = 1;
continue;
} }
if (!AST_VECTOR_SIZE(&missingdeps)) { if (!AST_VECTOR_SIZE(&missingdeps)) {
ast_log(LOG_WARNING, "%s isn't missing any dependencies but still didn't start\n", ast_log(LOG_WARNING, "%s load function returned an invalid result. "
ast_module_name(mod)); "This is a bug in the module.\n", ast_module_name(mod));
/* Dependencies were met but the module failed to start. */ /* Dependencies were met but the module failed to start and the result
* code was not AST_MODULE_LOAD_FAILURE or AST_MODULE_LOAD_DECLINE. */
res = -1; res = -1;
break; break;
} }
...@@ -1637,17 +1643,17 @@ static int start_resource_list(struct module_vector *resources, int *mod_count) ...@@ -1637,17 +1643,17 @@ static int start_resource_list(struct module_vector *resources, int *mod_count)
} }
if (AST_VECTOR_SIZE(&missingdeps)) { if (AST_VECTOR_SIZE(&missingdeps)) {
ast_log(LOG_ERROR, "Failed to load %s due to unfilled dependencies.\n", ast_log(LOG_WARNING, "Failed to load %s due to unfilled dependencies.\n",
ast_module_name(mod)); ast_module_name(mod));
res = -1; mod->flags.declined = 1;
break; AST_VECTOR_RESET(&missingdeps, AST_VECTOR_ELEM_CLEANUP_NOOP);
}
res = start_resource_attempt(mod, mod_count); continue;
if (res) {
ast_log(LOG_ERROR, "Failed to load %s: %d\n", ast_module_name(mod), res);
break;
} }
/* If we're here it means that we started with missingdeps and they're all loaded
* now. It's impossible to reach this point a second time for the same module. */
goto retry_load;
} }
AST_VECTOR_FREE(&missingdeps); AST_VECTOR_FREE(&missingdeps);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment