[asterisk-commits] file: branch 10 r373910 - in /branches/10: ./ main/loader.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Sep 27 11:50:50 CDT 2012
Author: file
Date: Thu Sep 27 11:50:46 2012
New Revision: 373910
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=373910
Log:
loader: Ensure dependent modules are properly initialized.
If an Asterisk module specifies a dependency in ast_module_info.nonoptreq, it
is possible for Asterisk to skip calling the modules's .load function.
Asterisk was loading and linking the module via load_dynamic_module() but was
not adding the module to the resource_heap. Therefore the module was not
initialized based on it's priority along with the other modules in the heap.
Now use load_resource() instead of load_dynamic_module() for non-optional
requirement. This will add the module to the resource_heap so the module can
be properly initialized in the correct order.
This is required if there are any module global data structures initialized in
the .load() callback for the module on platforms which do not support weak
references.
(issue ASTERISK-20439)
Reported by: sruffell
Patches:
0001-loader-Ensure-dependent-modules-are-properly-initial.patch uploaded by sruffell (license 5417)
........
Merged revisions 373909 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Modified:
branches/10/ (props changed)
branches/10/main/loader.c
Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/10/main/loader.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/loader.c?view=diff&rev=373910&r1=373909&r2=373910
==============================================================================
--- branches/10/main/loader.c (original)
+++ branches/10/main/loader.c Thu Sep 27 11:50:46 2012
@@ -371,7 +371,9 @@
while (!dlclose(lib));
}
-static struct ast_module *load_dynamic_module(const char *resource_in, unsigned int global_symbols_only)
+static enum ast_module_load_result load_resource(const char *resource_name, unsigned int global_symbols_only, struct ast_heap *resource_heap, int required);
+
+static struct ast_module *load_dynamic_module(const char *resource_in, unsigned int global_symbols_only, struct ast_heap *resource_heap)
{
char fn[PATH_MAX] = "";
void *lib = NULL;
@@ -440,11 +442,12 @@
/* Force any required dependencies to load */
char *each, *required_resource = ast_strdupa(mod->info->nonoptreq);
while ((each = strsep(&required_resource, ","))) {
+ struct ast_module *dependency;
each = ast_strip(each);
-
+ dependency = find_resource(each, 0);
/* Is it already loaded? */
- if (!find_resource(each, 0)) {
- load_dynamic_module(each, global_symbols_only);
+ if (!dependency) {
+ load_resource(each, global_symbols_only, resource_heap, 1);
}
}
}
@@ -802,6 +805,10 @@
char tmp[256];
enum ast_module_load_result res;
+ if (mod->flags.running) {
+ return AST_MODULE_LOAD_SUCCESS;
+ }
+
if (!mod->info->load) {
return AST_MODULE_LOAD_FAILURE;
}
@@ -857,7 +864,7 @@
return AST_MODULE_LOAD_SKIP;
} else {
#ifdef LOADABLE_MODULES
- if (!(mod = load_dynamic_module(resource_name, global_symbols_only))) {
+ if (!(mod = load_dynamic_module(resource_name, global_symbols_only, resource_heap))) {
/* don't generate a warning message during load_modules() */
if (!global_symbols_only) {
ast_log(LOG_WARNING, "Module '%s' could not be loaded.\n", resource_name);
More information about the asterisk-commits
mailing list