diff options
author | Sean Bright <sean.bright@gmail.com> | 2017-03-24 08:43:05 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2017-03-27 10:36:23 -0400 |
commit | 79a2c26c035bcd05250f2f09d6cc3cd65790535d (patch) | |
tree | dcd9df3d2532aa584c16025cabe42306047a599a /main/loader.c | |
parent | 39fff2ebf9356eaceac6aa0c783a8616cc3b9491 (diff) |
core: Remove embedded module support
This has not worked for some time and is no longer actively maintained.
Change-Id: I5110b0db69c152761b58fa025cb0a53b0e544d99
Diffstat (limited to 'main/loader.c')
-rw-r--r-- | main/loader.c | 94 |
1 files changed, 10 insertions, 84 deletions
diff --git a/main/loader.c b/main/loader.c index 74254b4fa..c135edc36 100644 --- a/main/loader.c +++ b/main/loader.c @@ -111,10 +111,6 @@ static const unsigned char expected_key[] = static char buildopt_sum[33] = AST_BUILDOPT_SUM; -static unsigned int embedding = 1; /* we always start out by registering embedded modules, - since they are here before we dlopen() any - */ - /*! * \brief Internal flag to indicate all modules have been initially loaded. */ @@ -150,14 +146,6 @@ const char *ast_module_name(const struct ast_module *mod) return mod->info->name; } -/* - * module_list is cleared by its constructor possibly after - * we start accumulating embedded modules, so we need to - * use another list (without the lock) to accumulate them. - * Then we update the main list when embedding is done. - */ -static struct module_list embedded_module_list; - struct loadupdate { int (*updater)(void); AST_LIST_ENTRY(loadupdate) entry; @@ -186,15 +174,7 @@ static struct ast_module *resource_being_loaded; void ast_module_register(const struct ast_module_info *info) { - struct ast_module *mod; - - if (embedding) { - if (!(mod = ast_calloc(1, sizeof(*mod) + strlen(info->name) + 1))) - return; - strcpy(mod->resource, info->name); - } else { - mod = resource_being_loaded; - } + struct ast_module *mod = resource_being_loaded; ast_debug(5, "Registering module %s\n", info->name); @@ -210,18 +190,14 @@ void ast_module_register(const struct ast_module_info *info) might be unsafe to use the list lock at that point... so let's avoid it altogether */ - if (embedding) { - AST_DLLIST_INSERT_TAIL(&embedded_module_list, mod, entry); - } else { - AST_DLLIST_LOCK(&module_list); - /* it is paramount that the new entry be placed at the tail of - the list, otherwise the code that uses dlopen() to load - dynamic modules won't be able to find out if the module it - just opened was registered or failed to load - */ - AST_DLLIST_INSERT_TAIL(&module_list, mod, entry); - AST_DLLIST_UNLOCK(&module_list); - } + AST_DLLIST_LOCK(&module_list); + /* it is paramount that the new entry be placed at the tail of + the list, otherwise the code that uses dlopen() to load + dynamic modules won't be able to find out if the module it + just opened was registered or failed to load + */ + AST_DLLIST_INSERT_TAIL(&module_list, mod, entry); + AST_DLLIST_UNLOCK(&module_list); /* give the module a copy of its own handle, for later use in registrations and the like */ *((struct ast_module **) &(info->self)) = mod; @@ -437,8 +413,6 @@ static struct ast_module *find_resource(const char *resource, int do_lock) return cur; } -#ifdef LOADABLE_MODULES - /*! * \brief dlclose(), with failure logging. */ @@ -611,8 +585,6 @@ static struct ast_module *load_dynamic_module(const char *resource_in, unsigned return AST_DLLIST_LAST(&module_list); } -#endif - int modules_shutdown(void) { struct ast_module *mod; @@ -729,18 +701,11 @@ int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode f AST_DLLIST_UNLOCK(&module_list); - if (!error && !mod->lib && mod->info && mod->info->restore_globals) - mod->info->restore_globals(); - -#ifdef LOADABLE_MODULES if (!error) { unload_dynamic_module(mod); ast_test_suite_event_notify("MODULE_UNLOAD", "Message: %s", resource_name); - } -#endif - - if (!error) ast_update_use_count(); + } return res; } @@ -1080,7 +1045,6 @@ static enum ast_module_load_result load_resource(const char *resource_name, unsi if (global_symbols_only && !ast_test_flag(mod->info, AST_MODFLAG_GLOBAL_SYMBOLS)) return AST_MODULE_LOAD_SKIP; } else { -#ifdef LOADABLE_MODULES mod = load_dynamic_module(resource_name, global_symbols_only, suppress_logging, resource_heap); if (mod == MODULE_LOCAL_ONLY) { return AST_MODULE_LOAD_SKIP; @@ -1091,22 +1055,11 @@ static enum ast_module_load_result load_resource(const char *resource_name, unsi } return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; } -#else - ast_log(LOG_WARNING, "Module support is not available. Module '%s' could not be loaded.\n", resource_name); - return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; -#endif } if (inspect_module(mod)) { ast_log(LOG_WARNING, "Module '%s' could not be loaded.\n", resource_name); -#ifdef LOADABLE_MODULES unload_dynamic_module(mod); -#endif - return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; - } - - if (!mod->lib && mod->info->backup_globals && mod->info->backup_globals()) { - ast_log(LOG_WARNING, "Module '%s' was unable to backup its global data.\n", resource_name); return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; } @@ -1324,7 +1277,6 @@ done: int load_modules(unsigned int preload_only) { struct ast_config *cfg; - struct ast_module *mod; struct load_order_entry *order; struct ast_variable *v; unsigned int load_count; @@ -1332,14 +1284,8 @@ int load_modules(unsigned int preload_only) int res = 0; struct ast_flags config_flags = { 0 }; int modulecount = 0; - -#ifdef LOADABLE_MODULES struct dirent *dirent; DIR *dir; -#endif - - /* all embedded modules have registered themselves by now */ - embedding = 0; ast_verb(1, "Asterisk Dynamic Loader Starting:\n"); @@ -1347,12 +1293,6 @@ int load_modules(unsigned int preload_only) AST_DLLIST_LOCK(&module_list); - if (embedded_module_list.first) { - module_list.first = embedded_module_list.first; - module_list.last = embedded_module_list.last; - embedded_module_list.first = NULL; - } - cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags); if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); @@ -1374,19 +1314,6 @@ int load_modules(unsigned int preload_only) /* check if 'autoload' is on */ if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) { - /* if so, first add all the embedded modules that are not already running to the load order */ - AST_DLLIST_TRAVERSE(&module_list, mod, entry) { - /* if it's not embedded, skip it */ - if (mod->lib) - continue; - - if (mod->flags.running) - continue; - - add_to_load_order(mod->resource, &load_order, 0); - } - -#ifdef LOADABLE_MODULES /* if we are allowed to load dynamic modules, scan the directory for for all available modules and add them as well */ if ((dir = opendir(ast_config_AST_MODULE_DIR))) { @@ -1415,7 +1342,6 @@ int load_modules(unsigned int preload_only) ast_log(LOG_WARNING, "Unable to open modules directory '%s'.\n", ast_config_AST_MODULE_DIR); } -#endif } /* now scan the config for any modules we are prohibited from loading and |