Asterisk - The Open Source Telephony Project GIT-master-5782b03
|
Module Loader. More...
#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/paths.h"
#include <dirent.h>
#include "asterisk/dlinkedlists.h"
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/channel.h"
#include "asterisk/term.h"
#include "asterisk/manager.h"
#include "asterisk/io.h"
#include "asterisk/lock.h"
#include "asterisk/vector.h"
#include "asterisk/app.h"
#include "asterisk/test.h"
#include "asterisk/cli.h"
#include <dlfcn.h>
#include "asterisk/md5.h"
#include "asterisk/utils.h"
Go to the source code of this file.
Data Structures | |
struct | ast_module |
struct | ast_module_user |
struct | load_order |
struct | load_order_entry |
struct | load_results_map |
struct | load_retries |
struct | loadupdate |
struct | module_list |
struct | module_load_word |
struct | module_user_list |
struct | module_vector |
struct | reload_queue |
struct | reload_queue_item |
struct | updaters |
Macros | |
#define | AST_MODULE_LOAD_UNKNOWN_STRING "Unknown" /* Status string for unknown load status */ |
#define | key_matches(a, b) (memcmp((a), (b), 16) == 0) |
#define | RTLD_LOCAL 0 |
#define | RTLD_NOW 0 |
#define | STR_APPEND_TEXT(txt, str) |
Functions | |
struct ast_module * | __ast_module_ref (struct ast_module *mod, const char *file, int line, const char *func) |
struct ast_module * | __ast_module_running_ref (struct ast_module *mod, const char *file, int line, const char *func) |
void | __ast_module_shutdown_ref (struct ast_module *mod, const char *file, int line, const char *func) |
void | __ast_module_unref (struct ast_module *mod, const char *file, int line, const char *func) |
struct ast_module_user * | __ast_module_user_add (struct ast_module *mod, struct ast_channel *chan) |
void | __ast_module_user_hangup_all (struct ast_module *mod) |
void | __ast_module_user_remove (struct ast_module *mod, struct ast_module_user *u) |
static struct load_order_entry * | add_to_load_order (const char *resource, struct load_order *load_order, int required, int preload, int builtin) |
static int | alpha_module_list_create (struct module_vector *alpha_module_list) |
enum ast_module_load_result | ast_load_resource (const char *resource_name) |
Load a module. More... | |
int | ast_loader_register (int(*v)(void)) |
Add a procedure to be run when modules have been updated. More... | |
int | ast_loader_unregister (int(*v)(void)) |
Remove a procedure to be run when modules are updated. More... | |
int | ast_module_check (const char *name) |
Check if module exists. More... | |
char * | ast_module_helper (const char *line, const char *word, int pos, int state, int rpos, enum ast_module_helper_type type) |
Match modules names for the Asterisk cli. More... | |
const char * | ast_module_name (const struct ast_module *mod) |
Get the name of a module. More... | |
void | ast_module_register (const struct ast_module_info *info) |
enum ast_module_reload_result | ast_module_reload (const char *name) |
Reload asterisk modules. More... | |
const char * | ast_module_support_level_to_string (enum ast_module_support_level support_level) |
void | ast_module_unregister (const struct ast_module_info *info) |
void | ast_process_pending_reloads (void) |
Process reload requests received during startup. More... | |
int | ast_refresh_resource (const char *resource_name, enum ast_module_unload_mode force, int recursive) |
Unload and load a module again. More... | |
int | ast_unload_resource (const char *resource_name, enum ast_module_unload_mode force) |
Unload a module. More... | |
int | ast_update_module_list (int(*modentry)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level), const char *like) |
Ask for a list of modules, descriptions, use counts and status. More... | |
int | ast_update_module_list_condition (int(*modentry)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level, void *data, const char *condition), const char *like, void *data, const char *condition) |
Ask for a list of modules, descriptions, use counts and status. More... | |
int | ast_update_module_list_data (int(*modentry)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level, void *data), const char *like, void *data) |
Ask for a list of modules, descriptions, use counts and status. More... | |
void | ast_update_use_count (void) |
Notify when usecount has been changed. More... | |
static int | auto_unload_resource (const char *resource_name, enum ast_module_unload_mode force, int recursive, struct ast_vector_const_string *dependents) |
Unload a resource. More... | |
static struct ast_module * | find_resource (const char *resource, int do_lock) |
static char * | get_name_from_resource (const char *resource) |
static int | graceful_unload_possible (struct ast_module *target, struct ast_vector_const_string *dependents) |
Whether or not this module should be able to be unloaded successfully, if we recursively unload any modules that are dependent on it. More... | |
static unsigned int | inspect_module (const struct ast_module *mod) |
static int | is_module_loaded (const char *resource_name) |
Check to see if the given resource is loaded. More... | |
static struct ast_module * | load_dlopen (const char *resource_in, const char *so_ext, const char *filename, int flags, unsigned int suppress_logging) |
static int | load_dlopen_missing (struct ast_str **list, struct ast_vector_string *deps) |
static struct ast_module * | load_dynamic_module (const char *resource_in, unsigned int suppress_logging) |
int | load_modules (void) |
static enum ast_module_load_result | load_resource (const char *resource_name, unsigned int suppress_logging, struct module_vector *module_priorities, int required, int preload) |
static int | load_resource_list (struct load_order *load_order, int *mod_count) |
static int | loader_builtin_init (struct load_order *load_order) |
static int | loader_config_init (struct load_order *load_order) |
static const char * | loadresult2str (enum ast_module_load_result result) |
static void | logged_dlclose (const char *name, void *lib) |
dlclose(), with failure logging. More... | |
static int | module_deps_missing_recursive (struct ast_module *mod, struct module_vector *missingdeps) |
Recursively find required dependencies that are not running. More... | |
static int | module_deps_process_reqlist (struct ast_module *mod, struct ast_vector_string *vec, struct ast_vector_const_string *missing, int ref_enhancers, int isoptional) |
static int | module_deps_reference (struct ast_module *mod, struct ast_vector_const_string *missing) |
static void | module_destroy (struct ast_module *mod) |
static void | module_load_error (const char *fmt,...) |
static void | module_load_helper (const char *word) |
static int | module_load_helper_on_file (const char *dir_name, const char *filename, void *obj) |
static int | module_matches_helper_type (struct ast_module *mod, enum ast_module_helper_type type) |
static int | module_post_register (struct ast_module *mod) |
static int | module_reffed_deps_add (struct ast_module *mod, struct ast_module *dep, struct ast_vector_const_string *missing) |
static int | module_reffed_deps_add_dep_enhancers (struct ast_module *mod, struct ast_module *dep, struct ast_vector_const_string *missing) |
static int | module_vector_cmp (struct ast_module *a, struct ast_module *b) |
static int | module_vector_strcasecmp (struct ast_module *a, struct ast_module *b) |
int | modules_shutdown (void) |
static int | printdigest (const unsigned char *d) |
static void | publish_load_message (const char *name, enum ast_module_load_result result) |
static void | publish_load_message_type (const char *type, const char *name, const char *status) |
static void | publish_reload_message (const char *name, enum ast_module_reload_result result) |
static void | publish_unload_message (const char *name, const char *status) |
static void | queue_reload_request (const char *module) |
static int | resource_list_recursive_decline (struct module_vector *resources, struct ast_module *mod, struct ast_str **printmissing) |
static size_t | resource_name_baselen (const char *name) |
static int | resource_name_match (const char *name1, size_t baselen1, const char *name2) |
static enum ast_module_load_result | start_resource (struct ast_module *mod) |
static enum ast_module_load_result | start_resource_attempt (struct ast_module *mod, int *count) |
static int | start_resource_list (struct module_vector *resources, int *mod_count) |
static void | unload_dynamic_module (struct ast_module *mod) |
static int | verify_key (const unsigned char *key) |
Variables | |
static char | buildopt_sum [33] = AST_BUILDOPT_SUM |
static struct module_list | builtin_module_list |
static int | do_full_reload = 0 |
static const unsigned char | expected_key [] |
static const struct load_results_map | load_results [] |
static unsigned int | loader_ready |
static struct module_list | module_list = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , } |
static int | modules_loaded |
Internal flag to indicate all modules have been initially loaded. More... | |
static struct reload_queue | reload_queue = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , } |
static ast_mutex_t | reloadlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static struct ast_module *volatile | resource_being_loaded |
static struct ast_str * | startup_error_builder |
static struct ast_vector_string | startup_errors |
const char * | support_level_map [] |
static struct updaters | updaters = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , } |
Module Loader.
Definition in file loader.c.
#define STR_APPEND_TEXT | ( | txt, | |
str | |||
) |
Used with AST_VECTOR_CALLBACK_VOID to create a comma separated list of module names for error messages.
struct ast_module * __ast_module_ref | ( | struct ast_module * | mod, |
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Definition at line 2868 of file loader.c.
References __ao2_ref(), ast_atomic_fetchadd_int(), ast_update_use_count(), make_ari_stubs::file, NULL, ast_module::ref_debug, and ast_module::usecount.
Referenced by __ast_module_running_ref(), and __ast_module_shutdown_ref().
struct ast_module * __ast_module_running_ref | ( | struct ast_module * | mod, |
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Definition at line 2884 of file loader.c.
References __ast_module_ref(), make_ari_stubs::file, ast_module::flags, NULL, and ast_module::running.
void __ast_module_shutdown_ref | ( | struct ast_module * | mod, |
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Definition at line 2894 of file loader.c.
References __ast_module_ref(), make_ari_stubs::file, ast_module::flags, and ast_module::keepuntilshutdown.
void __ast_module_unref | ( | struct ast_module * | mod, |
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Definition at line 2904 of file loader.c.
References __ao2_ref(), ast_atomic_fetchadd_int(), ast_update_use_count(), make_ari_stubs::file, ast_module::ref_debug, and ast_module::usecount.
struct ast_module_user * __ast_module_user_add | ( | struct ast_module * | mod, |
struct ast_channel * | chan | ||
) |
Definition at line 800 of file loader.c.
References ao2_ref, ast_atomic_fetchadd_int(), ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_update_use_count(), ast_module_user::chan, NULL, ast_module::ref_debug, ast_module::usecount, and ast_module::users.
Referenced by ast_func_read(), ast_func_read2(), ast_func_write(), and pbx_exec().
void __ast_module_user_hangup_all | ( | struct ast_module * | mod | ) |
Definition at line 853 of file loader.c.
References ao2_ref, ast_atomic_fetchadd_int(), ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, ast_update_use_count(), ast_module_user::chan, ast_module::ref_debug, ast_module::usecount, and ast_module::users.
Referenced by auto_unload_resource().
void __ast_module_user_remove | ( | struct ast_module * | mod, |
struct ast_module_user * | u | ||
) |
Definition at line 826 of file loader.c.
References ao2_ref, ast_atomic_fetchadd_int(), ast_free, AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_UNLOCK, ast_update_use_count(), ast_module::ref_debug, ast_module::usecount, and ast_module::users.
Referenced by ast_func_read(), ast_func_read2(), ast_func_write(), and pbx_exec().
|
static |
Definition at line 2012 of file loader.c.
References ast_calloc, ast_free, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_strdup, load_order_entry::builtin, NULL, order, load_order_entry::preload, load_order_entry::required, load_order_entry::resource, resource_name_baselen(), and resource_name_match().
Referenced by loader_builtin_init(), and loader_config_init().
|
static |
Definition at line 2720 of file loader.c.
References AST_DLLIST_TRAVERSE, AST_VECTOR_ADD_SORTED, AST_VECTOR_INIT, and module_vector_strcasecmp().
Referenced by ast_update_module_list(), ast_update_module_list_condition(), and ast_update_module_list_data().
enum ast_module_load_result ast_load_resource | ( | const char * | resource_name | ) |
Load a module.
resource_name | The name of the module to load. |
This function is run by the PBX to load the modules. It performs all loading and initialization tasks. Basically, to load a module, just give it the name of the module and it will do the rest.
Definition at line 1978 of file loader.c.
References ast_debug, AST_DLLIST_LOCK, AST_DLLIST_UNLOCK, ast_test_suite_event_notify, ast_unload_resource(), ast_module::declined, find_resource(), ast_module::flags, load_resource(), and NULL.
Referenced by ast_ari_asterisk_load_module(), ast_refresh_resource(), auto_unload_resource(), handle_load(), and manager_moduleload().
int ast_loader_register | ( | int(*)(void) | updater | ) |
Add a procedure to be run when modules have been updated.
updater | The function to run when modules have been updated. |
This function adds the given function to a linked list of functions to be run when the modules are updated.
0 | on success |
-1 | on failure. |
Definition at line 2836 of file loader.c.
int ast_loader_unregister | ( | int(*)(void) | updater | ) |
Remove a procedure to be run when modules are updated.
updater | The updater function to unregister. |
This removes the given function from the updater list.
0 | on success |
-1 | on failure. |
Definition at line 2851 of file loader.c.
int ast_module_check | ( | const char * | name | ) |
Check if module exists.
Check if module with the name given is loaded.
Definition at line 2823 of file loader.c.
References ast_strlen_zero(), find_resource(), name, and NULL.
Referenced by ast_ari_asterisk_get_module(), ast_ari_asterisk_load_module(), ast_ari_asterisk_reload_module(), ast_ari_asterisk_unload_module(), AST_TEST_DEFINE(), ifmodule_read(), load_module(), and manager_modulecheck().
char * ast_module_helper | ( | const char * | line, |
const char * | word, | ||
int | pos, | ||
int | state, | ||
int | rpos, | ||
enum ast_module_helper_type | type | ||
) |
Match modules names for the Asterisk cli.
line | Unused by this function, but this should be the line we are matching. |
word | The partial name to match. |
pos | The position the word we are completing is in. |
state | The possible match to return. |
rpos | The position we should be matching. This should be the same as pos. |
type | The type of action that will be performed by CLI. |
A | possible completion of the partial match. |
NULL | if no matches were found or Asterisk is not yet fully booted. |
Definition at line 1528 of file loader.c.
References AST_DLLIST_LOCK, AST_DLLIST_TRAVERSE, AST_DLLIST_UNLOCK, AST_MODULE_HELPER_LOAD, AST_OPT_FLAG_FULLY_BOOTED, ast_options, ast_strdup, ast_test_flag, module_load_helper(), module_matches_helper_type(), NULL, ast_module::resource, and type.
Referenced by handle_debug(), handle_load(), handle_modlist(), handle_refresh(), handle_reload(), handle_trace(), and handle_unload().
const char * ast_module_name | ( | const struct ast_module * | mod | ) |
Get the name of a module.
mod | A pointer to the module. |
NULL | if mod or mod->info is NULL |
Definition at line 615 of file loader.c.
References ast_module::info, ast_module_info::name, and NULL.
Referenced by acf_retrieve_docs(), ast_register_application2(), graceful_unload_possible(), resource_list_recursive_decline(), start_resource_list(), and unload_dynamic_module().
void ast_module_register | ( | const struct ast_module_info * | info | ) |
Definition at line 659 of file loader.c.
Referenced by loader_builtin_init().
enum ast_module_reload_result ast_module_reload | ( | const char * | name | ) |
Reload asterisk modules.
name | the name of the module to reload |
This function reloads the specified module, or if no modules are specified, it will reload all loaded modules.
The | ast_module_reload_result status of the module load request |
Definition at line 1721 of file loader.c.
References ast_config_AST_CONFIG_DIR, AST_DLLIST_LOCK, AST_DLLIST_TRAVERSE, AST_DLLIST_UNLOCK, ast_lastreloadtime, ast_lock_path(), AST_LOCK_SUCCESS, AST_LOCK_TIMEOUT, ast_log, AST_LOG_WARNING, AST_MODULE_LOAD_SUCCESS, AST_MODULE_RELOAD_ERROR, AST_MODULE_RELOAD_IN_PROGRESS, AST_MODULE_RELOAD_NOT_FOUND, AST_MODULE_RELOAD_NOT_IMPLEMENTED, AST_MODULE_RELOAD_QUEUED, AST_MODULE_RELOAD_SUCCESS, AST_MODULE_RELOAD_UNINITIALIZED, ast_mutex_trylock, ast_mutex_unlock, ast_opt_lock_confdir, ast_sd_notify(), ast_tvnow(), ast_unlock_path(), ast_verb, ast_module::declined, ast_module::flags, sip_to_pjsip::info(), ast_module::info, LOG_WARNING, modules_loaded, name, publish_reload_message(), queue_reload_request(), reloadlock, ast_module::resource, resource_name_baselen(), resource_name_match(), and ast_module::running.
Referenced by action_reload(), action_updateconfig(), ast_ari_asterisk_reload_module(), ast_process_pending_reloads(), handle_cli_ael_reload(), handle_cli_moh_reload(), handle_core_reload(), handle_reload(), manager_moduleload(), monitor_sig_flags(), and reload_exec().
const char * ast_module_support_level_to_string | ( | enum ast_module_support_level | support_level | ) |
Definition at line 2925 of file loader.c.
References support_level_map.
Referenced by identify_module(), modlist_modentry(), and process_module_list().
void ast_module_unregister | ( | const struct ast_module_info * | info | ) |
Definition at line 768 of file loader.c.
void ast_process_pending_reloads | ( | void | ) |
Process reload requests received during startup.
This function requests that the loader execute the pending reload requests that were queued during server startup.
Definition at line 1566 of file loader.c.
References ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_log, ast_module_reload(), do_full_reload, item, LOG_NOTICE, modules_loaded, and NULL.
Referenced by asterisk_daemon().
int ast_refresh_resource | ( | const char * | resource_name, |
enum ast_module_unload_mode | force, | ||
int | recursive | ||
) |
Unload and load a module again.
resource_name | The name of the module to unload. |
ast_module_unload_mode | The force flag. This should be set using one of the AST_FORCE flags. |
recursive | Attempt to recursively unload any dependents of this module if that will allow the module to unload, and load them back again afterwards. |
0 | on success. |
1 | on error unloading modules. |
-1 | on error loading modules back. |
Definition at line 1407 of file loader.c.
References ast_load_resource(), ast_log, ast_unload_resource(), AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_SIZE, auto_unload_resource(), and LOG_WARNING.
Referenced by handle_refresh(), and manager_moduleload().
int ast_unload_resource | ( | const char * | resource_name, |
enum | ast_module_unload_mode | ||
) |
Unload a module.
resource_name | The name of the module to unload. |
ast_module_unload_mode | The force flag. This should be set using one of the AST_FORCE flags. |
This function unloads a module. It will only unload modules that are not in use (usecount not zero), unless AST_FORCE_FIRM or AST_FORCE_HARD is specified. Setting AST_FORCE_FIRM or AST_FORCE_HARD will unload the module regardless of consequences (NOT RECOMMENDED).
0 | on success. |
-1 | on error. |
Definition at line 1448 of file loader.c.
References auto_unload_resource(), and NULL.
Referenced by ast_ari_asterisk_unload_module(), ast_load_resource(), ast_refresh_resource(), auto_unload_resource(), handle_unload(), manager_moduleload(), and unload_module().
int ast_update_module_list | ( | int(*)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level) | modentry, |
const char * | like | ||
) |
Ask for a list of modules, descriptions, use counts and status.
modentry | A callback to an updater function. |
like |
For each of the modules loaded, modentry will be executed with the resource, description, and usecount values of each particular module.
Definition at line 2737 of file loader.c.
References alpha_module_list_create(), AST_DLLIST_LOCK, AST_DLLIST_UNLOCK, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_module_info::description, ast_module::flags, ast_module::info, ast_module::resource, ast_module::running, ast_module_info::support_level, and ast_module::usecount.
Referenced by ast_var_Modules(), and handle_modlist().
int ast_update_module_list_condition | ( | int(*)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level, void *data, const char *condition) | modentry, |
const char * | like, | ||
void * | data, | ||
const char * | condition | ||
) |
Ask for a list of modules, descriptions, use counts and status.
modentry | A callback to an updater function |
like | |
data | Data passed into the callback for manipulation |
condition | The condition to meet |
For each of the modules loaded, modentry will be executed with the resource, description, and usecount values of each particular module.
Definition at line 2792 of file loader.c.
References alpha_module_list_create(), AST_DLLIST_LOCK, AST_DLLIST_UNLOCK, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_module_info::description, ast_module::flags, ast_module::info, ast_module::resource, ast_module::running, ast_module_info::support_level, and ast_module::usecount.
Referenced by ast_ari_asterisk_get_module().
int ast_update_module_list_data | ( | int(*)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level, void *data) | modentry, |
const char * | like, | ||
void * | data | ||
) |
Ask for a list of modules, descriptions, use counts and status.
modentry | A callback to an updater function |
like | |
data | Data passed into the callback for manipulation |
For each of the modules loaded, modentry will be executed with the resource, description, and usecount values of each particular module.
Definition at line 2764 of file loader.c.
References alpha_module_list_create(), AST_DLLIST_LOCK, AST_DLLIST_UNLOCK, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_module_info::description, ast_module::flags, ast_module::info, ast_module::resource, ast_module::running, ast_module_info::support_level, and ast_module::usecount.
Referenced by ast_ari_asterisk_list_modules().
void ast_update_use_count | ( | void | ) |
Notify when usecount has been changed.
This function calculates use counts and notifies anyone trying to keep track of them. It should be called whenever your module's usecount changes.
Definition at line 2698 of file loader.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, and loadupdate::updater.
Referenced by __ast_module_ref(), __ast_module_unref(), __ast_module_user_add(), __ast_module_user_hangup_all(), __ast_module_user_remove(), auto_unload_resource(), ooh323_hangup(), ooh323_new(), ooh323c_call_thread(), start_resource(), and unistim_new().
|
static |
Unload a resource.
resource_name | Module name |
force | |
recursive | Whether to attempt to recursively unload dependents of this module and load them again afterwards |
dependents. | Can be NULL if autounload is 0. |
0 | on success, -1 on failure |
Definition at line 1285 of file loader.c.
References __ast_module_user_hangup_all(), ast_debug, AST_DLLIST_LOCK, AST_DLLIST_UNLOCK, AST_FORCE_FIRM, ast_load_resource(), ast_log, ast_test_suite_event_notify, ast_unload_resource(), ast_update_use_count(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_verb, ast_module::declined, error(), ESS, find_resource(), ast_module::flags, graceful_unload_possible(), ast_module::info, LOG_NOTICE, LOG_WARNING, publish_unload_message(), ast_module::resource, ast_module::running, ast_module_info::unload, unload_dynamic_module(), and ast_module::usecount.
Referenced by ast_refresh_resource(), and ast_unload_resource().
|
static |
Definition at line 927 of file loader.c.
References AST_DLLIST_LOCK, AST_DLLIST_TRAVERSE, AST_DLLIST_UNLOCK, ast_module::resource, resource_name_baselen(), and resource_name_match().
Referenced by ast_load_resource(), ast_module_check(), auto_unload_resource(), load_dlopen_missing(), load_resource(), loader_config_init(), module_deps_missing_recursive(), module_deps_process_reqlist(), and module_load_helper_on_file().
|
static |
Definition at line 157 of file loader.c.
References ast_calloc, ast_copy_string(), len(), and NULL.
Referenced by load_modules().
|
static |
Whether or not this module should be able to be unloaded successfully, if we recursively unload any modules that are dependent on it.
0 | if not, 1 if likely possible |
Definition at line 1225 of file loader.c.
References ast_debug, AST_DLLIST_TRAVERSE, ast_log, ast_module_name(), ast_strdup, AST_VECTOR_ELEM_DEFAULT_CMP, AST_VECTOR_GET_CMP, AST_VECTOR_INSERT_AT, graceful_unload_possible(), LOG_ERROR, LOG_NOTICE, name, ast_module::reffed_deps, and ast_module::usecount.
Referenced by auto_unload_resource(), and graceful_unload_possible().
|
static |
Definition at line 1810 of file loader.c.
References ast_strlen_zero(), ast_module_info::buildopt_sum, buildopt_sum, ast_module_info::description, ast_module::info, ast_module_info::key, module_load_error(), ast_module::resource, and verify_key().
Referenced by load_resource().
|
static |
Check to see if the given resource is loaded.
resource_name | Name of the resource, including .so suffix. |
Definition at line 981 of file loader.c.
References ast_config_AST_MODULE_DIR, ast_module::lib, logged_dlclose(), and PATH_MAX.
Referenced by unload_dynamic_module().
|
static |
Definition at line 1060 of file loader.c.
References ast_assert, ast_calloc, ast_free, ast_str_buffer(), ast_str_create, ast_str_strlen(), ast_strdupa, c, ast_module::enhances, ast_module::flags, ast_module::lib, load_dlopen_missing(), logged_dlclose(), module_load_error(), module_post_register(), NULL, ast_module::optional_modules, ast_module::requires, ast_module::resource, resource_being_loaded, RTLD_LOCAL, S_OR, and unload_dynamic_module().
Referenced by load_dynamic_module().
|
static |
Definition at line 1030 of file loader.c.
References AST_VECTOR_GET, AST_VECTOR_SIZE, c, find_resource(), and STR_APPEND_TEXT.
Referenced by load_dlopen().
|
static |
Definition at line 1145 of file loader.c.
References ast_config_AST_MODULE_DIR, AST_MODFLAG_GLOBAL_SYMBOLS, ast_test_flag, ast_module::info, ast_module::lib, load_dlopen(), logged_dlclose(), PATH_MAX, RTLD_LOCAL, and RTLD_NOW.
Referenced by load_resource().
int load_modules | ( | void | ) |
Provided by loader.c
Definition at line 2508 of file loader.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_container_alloc_list, ast_copy_string(), ast_debug, AST_DLLIST_LOCK, AST_DLLIST_TRAVERSE, AST_DLLIST_UNLOCK, ast_free, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE, ast_log, AST_MODULE_SUPPORT_DEPRECATED, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_reset(), ast_str_strlen(), ast_strlen_zero(), ast_tvdiff_us(), ast_tvnow(), AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_SIZE, ast_verb, ast_xml_find_element(), ast_xml_get_text(), ast_xml_node_get_children(), ast_xml_xpath_get_first_result(), ast_xml_xpath_results_free(), ast_xmldoc_query(), ast_module::declined, done, ast_module::flags, get_name_from_resource(), ast_module::info, load_resource_list(), loader_builtin_init(), loader_config_init(), LOG_ERROR, LOG_NOTICE, LOG_WARNING, NULL, order, ast_module::resource, ast_module::running, startup_error_builder, startup_errors, str, and ast_module_info::support_level.
Referenced by asterisk_daemon().
|
static |
loads a resource based upon resource_name. If global_symbols_only is set only modules with global symbols will be loaded.
If the module_vector is provided (not NULL) the module is found and added to the vector without running the module's load() function. By doing this, modules can be initialized later in order by priority and dependencies.
If the module_vector is not provided, the module's load function will be executed immediately
Definition at line 1922 of file loader.c.
References ast_fully_booted, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_PRIORITY, AST_MODULE_LOAD_SUCCESS, ast_shutdown_final(), AST_VECTOR_ADD_SORTED, ast_module::declined, find_resource(), ast_module::flags, inspect_module(), load_dynamic_module(), LOG_WARNING, module_load_error(), module_post_register(), module_vector_cmp(), ast_module::preload, publish_load_message(), ast_module::required, ast_module::running, start_resource(), and unload_dynamic_module().
Referenced by ast_load_resource(), and load_resource_list().
|
static |
loads modules in order by load_pri, updates mod_count
Definition at line 2271 of file loader.c.
References ast_debug, ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_PRIORITY, AST_MODULE_LOAD_SKIP, AST_MODULE_LOAD_SUCCESS, AST_VECTOR_FREE, AST_VECTOR_INIT, load_resource(), LOG_ERROR, module_load_error(), order, and start_resource_list().
Referenced by load_modules().
|
static |
Definition at line 2349 of file loader.c.
References add_to_load_order(), AST_DLLIST_REMOVE_HEAD, AST_DLLIST_TRAVERSE, ast_module_register(), ast_module::builtin, builtin_module_list, ast_module::flags, ast_module::info, loader_ready, module_post_register(), ast_module::resource, and resource_being_loaded.
Referenced by load_modules().
|
static |
Definition at line 2384 of file loader.c.
References add_to_load_order(), ast_config_AST_MODULE_DIR, ast_config_destroy(), ast_config_load2(), ast_debug, ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log, AST_MODULE_CONFIG, ast_true(), ast_variable_browse(), ast_variable_retrieve(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, done, find_resource(), LOG_ERROR, LOG_WARNING, ast_variable::name, ast_variable::next, order, resource_name_baselen(), resource_name_match(), and ast_variable::value.
Referenced by load_modules().
|
static |
Definition at line 1673 of file loader.c.
References ARRAY_LEN, ast_log, AST_MODULE_LOAD_UNKNOWN_STRING, load_results, LOG_WARNING, load_results_map::name, and result.
Referenced by publish_load_message().
|
static |
dlclose(), with failure logging.
Definition at line 952 of file loader.c.
References ast_log, AST_LOG_ERROR, error(), ast_module::lib, name, and S_OR.
Referenced by is_module_loaded(), load_dlopen(), load_dynamic_module(), and unload_dynamic_module().
|
static |
Recursively find required dependencies that are not running.
mod | Module to scan for dependencies. |
missingdeps | Vector listing modules that must be started first. |
0 | All dependencies resolved. |
-1 | Failed to resolve some dependencies. |
An error from this function usually means a required module is not even loaded. This function is safe from infinite recursion, but dependency loops are not reported as an error from here. On success missingdeps will contain a list of every module that needs to be running before this module can start. missingdeps is sorted by load priority so any missing dependencies can be started if needed.
Definition at line 566 of file loader.c.
References AST_VECTOR_ADD_SORTED, AST_VECTOR_ELEM_DEFAULT_CMP, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_GET_CMP, AST_VECTOR_INIT, AST_VECTOR_REMOVE, AST_VECTOR_SIZE, find_resource(), module_deps_missing_recursive(), module_deps_reference(), and module_vector_cmp().
Referenced by module_deps_missing_recursive(), resource_list_recursive_decline(), start_resource(), and start_resource_list().
|
static |
Definition at line 485 of file loader.c.
References AST_VECTOR_APPEND, AST_VECTOR_GET, AST_VECTOR_SIZE, find_resource(), ast_module::flags, module_reffed_deps_add(), module_reffed_deps_add_dep_enhancers(), and ast_module::running.
Referenced by module_deps_reference().
|
static |
Definition at line 534 of file loader.c.
References ast_module::enhances, module_deps_process_reqlist(), ast_module::optional_modules, and ast_module::requires.
Referenced by module_deps_missing_recursive(), start_resource(), start_resource_attempt(), and start_resource_list().
|
static |
Definition at line 744 of file loader.c.
References ao2_cleanup, ast_free, AST_LIST_HEAD_DESTROY, ast_module_unref, ast_std_free(), AST_VECTOR_CALLBACK_VOID, AST_VECTOR_FREE, ast_module::builtin, ast_module::enhances, ast_module::flags, ast_module::optional_modules, ast_module::ref_debug, ast_module::reffed_deps, ast_module::requires, and ast_module::users.
Referenced by ast_module_unregister(), and modules_shutdown().
|
static |
Definition at line 269 of file loader.c.
References ast_free, ast_log, ast_log_ap(), ast_str_buffer(), ast_str_set_va(), ast_strdup, AST_VECTOR_APPEND, copy(), LOG_ERROR, NULL, startup_error_builder, and startup_errors.
Referenced by inspect_module(), load_dlopen(), load_resource(), load_resource_list(), resource_list_recursive_decline(), start_resource(), start_resource_attempt(), and start_resource_list().
|
static |
Definition at line 1515 of file loader.c.
References ast_config_AST_MODULE_DIR, AST_DLLIST_LOCK, AST_DLLIST_UNLOCK, ast_file_read_dirs(), module_load_helper_on_file(), and module_load_word::word.
Referenced by ast_module_helper().
|
static |
Definition at line 1483 of file loader.c.
References ast_asprintf, ast_assert, ast_cli_completion_add(), ast_free, ast_strdup, ast_strlen_zero(), find_resource(), ast_module::flags, NULL, and ast_module::running.
Referenced by module_load_helper().
|
static |
Definition at line 1453 of file loader.c.
References ast_assert, AST_MODULE_HELPER_LOADED, AST_MODULE_HELPER_RELOAD, AST_MODULE_HELPER_RUNNING, AST_MODULE_HELPER_UNLOAD, ast_module::declined, ast_module::flags, ast_module::info, ast_module_info::reload, ast_module::running, type, and ast_module::usecount.
Referenced by ast_module_helper().
|
static |
Definition at line 732 of file loader.c.
References ast_vector_string_split(), ast_module_info::enhances, ast_module::enhances, ast_module::info, ast_module_info::optional_modules, ast_module::optional_modules, and ast_module::requires.
Referenced by load_dlopen(), load_resource(), and loader_builtin_init().
|
static |
Definition at line 416 of file loader.c.
References ast_module_ref, AST_VECTOR_APPEND, AST_VECTOR_ELEM_DEFAULT_CMP, AST_VECTOR_GET_CMP, ast_module::flags, ast_module::info, ast_module_info::name, ast_module::reffed_deps, and ast_module::running.
Referenced by module_deps_process_reqlist(), and module_reffed_deps_add_dep_enhancers().
|
static |
Definition at line 448 of file loader.c.
References AST_DLLIST_TRAVERSE, AST_VECTOR_GET_CMP, ast_module::declined, ast_module::enhances, ast_module::flags, ast_module::info, module_reffed_deps_add(), and ast_module_info::name.
Referenced by module_deps_process_reqlist().
|
static |
Definition at line 371 of file loader.c.
References a, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_DEFAULT, ast_test_flag, and b.
Referenced by load_resource(), and module_deps_missing_recursive().
|
static |
int modules_shutdown | ( | void | ) |
Provided by loader.c
Definition at line 1172 of file loader.c.
References ast_debug, AST_DLLIST_EMPTY, AST_DLLIST_LOCK, AST_DLLIST_REMOVE_CURRENT, AST_DLLIST_TRAVERSE, AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN, AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END, AST_DLLIST_UNLOCK, ast_module_unref, ast_verb, ast_module::declined, ast_module::flags, ast_module::info, ast_module::keepuntilshutdown, module_destroy(), ast_module::resource, ast_module::running, ast_module_info::unload, and ast_module::usecount.
Referenced by really_quit().
|
static |
|
static |
Definition at line 1690 of file loader.c.
References loadresult2str(), name, publish_load_message_type(), result, and status.
Referenced by load_resource().
|
static |
Definition at line 1634 of file loader.c.
References ao2_cleanup, ast_assert, ast_json_pack(), ast_json_payload_create(), ast_json_ref(), ast_json_unref(), ast_manager_get_generic_type(), ast_manager_get_topic(), ast_strlen_zero(), EVENT_FLAG_SYSTEM, name, NULL, RAII_VAR, stasis_message_create(), stasis_publish(), status, and type.
Referenced by publish_load_message(), publish_reload_message(), and publish_unload_message().
|
static |
Definition at line 1713 of file loader.c.
References name, publish_load_message_type(), result, and S_OR.
Referenced by ast_module_reload().
|
static |
Definition at line 1703 of file loader.c.
References name, publish_load_message_type(), and status.
Referenced by auto_unload_resource().
|
static |
Definition at line 1591 of file loader.c.
References ast_calloc, ast_free, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log, ast_strlen_zero(), do_full_reload, item, LOG_ERROR, and reload_queue_item::module.
Referenced by ast_module_reload().
|
static |
Definition at line 2076 of file loader.c.
References ast_module_name(), ast_str_buffer(), ast_str_create, ast_str_reset(), AST_VECTOR_APPEND, AST_VECTOR_CALLBACK_VOID, AST_VECTOR_ELEM_CLEANUP_NOOP, AST_VECTOR_ELEM_DEFAULT_CMP, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_GET_CMP, AST_VECTOR_INIT, AST_VECTOR_RESET, AST_VECTOR_SIZE, ast_module::declined, ast_module::flags, module_deps_missing_recursive(), module_load_error(), ast_module::required, and STR_APPEND_TEXT.
Referenced by start_resource_list().
|
static |
Definition at line 907 of file loader.c.
Referenced by add_to_load_order(), ast_module_reload(), find_resource(), loader_config_init(), and resource_name_match().
|
static |
Definition at line 918 of file loader.c.
References resource_name_baselen().
Referenced by add_to_load_order(), ast_module_reload(), find_resource(), and loader_config_init().
|
static |
Definition at line 1837 of file loader.c.
References AST_DLLIST_INSERT_TAIL, AST_DLLIST_LOCK, AST_DLLIST_REMOVE, AST_DLLIST_UNLOCK, ast_fully_booted, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_PRIORITY, AST_MODULE_LOAD_SKIP, AST_MODULE_LOAD_SUCCESS, ast_module_shutdown_ref, ast_update_use_count(), AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_SIZE, ast_verb, ast_module::builtin, COLOR_BLACK, COLOR_BROWN, ast_module::declined, ast_module_info::description, ast_module::flags, sip_to_pjsip::info(), ast_module::info, ast_module_info::load, module_deps_missing_recursive(), module_deps_reference(), module_load_error(), ast_module_info::name, NULL, ast_module::required, ast_module::resource, ast_module::running, term_color(), and tmp().
Referenced by load_resource(), and start_resource_attempt().
|
static |
Definition at line 2048 of file loader.c.
References ast_debug, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_DEFAULT, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SKIP, AST_MODULE_LOAD_SUCCESS, ast_test_flag, ast_module::flags, ast_module::info, ast_module_info::load_pri, module_deps_reference(), module_load_error(), NULL, ast_module::required, ast_module::resource, and start_resource().
Referenced by start_resource_list().
|
static |
Definition at line 2139 of file loader.c.
References ast_debug, ast_free, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_module_name(), ast_str_buffer(), ast_str_create, ast_str_reset(), AST_VECTOR_CALLBACK_VOID, AST_VECTOR_ELEM_CLEANUP_NOOP, AST_VECTOR_ELEM_DEFAULT_CMP, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_REMOVE, AST_VECTOR_REMOVE_CMP_ORDERED, AST_VECTOR_RESET, AST_VECTOR_SIZE, ast_module::declined, ast_module::flags, module_deps_missing_recursive(), module_deps_reference(), module_load_error(), NULL, resource_list_recursive_decline(), start_resource_attempt(), and STR_APPEND_TEXT.
Referenced by load_resource_list().
|
static |
Definition at line 1000 of file loader.c.
References ast_log, ast_module_name(), ast_strdupa, is_module_loaded(), ast_module::lib, LOG_WARNING, logged_dlclose(), and name.
Referenced by auto_unload_resource(), load_dlopen(), and load_resource().
|
static |
Definition at line 890 of file loader.c.
References c, expected_key, key_matches, MD5Final(), MD5Init(), MD5Update(), and printdigest().
Referenced by inspect_module().
|
static |
Definition at line 138 of file loader.c.
Referenced by inspect_module().
|
static |
Definition at line 364 of file loader.c.
Referenced by ast_module_register(), and loader_builtin_init().
|
static |
Definition at line 638 of file loader.c.
Referenced by ast_process_pending_reloads(), and queue_reload_request().
|
static |
Definition at line 134 of file loader.c.
Referenced by verify_key().
|
static |
Definition at line 344 of file loader.c.
Referenced by loadresult2str().
|
static |
Definition at line 150 of file loader.c.
Referenced by ast_module_register(), and loader_builtin_init().
|
static |
|
static |
Internal flag to indicate all modules have been initially loaded.
Definition at line 291 of file loader.c.
Referenced by ast_module_reload(), and ast_process_pending_reloads().
|
static |
|
static |
Definition at line 631 of file loader.c.
Referenced by ast_module_reload().
|
static |
Definition at line 650 of file loader.c.
Referenced by ast_module_register(), load_dlopen(), and loader_builtin_init().
|
static |
Definition at line 154 of file loader.c.
Referenced by load_modules(), and module_load_error().
|
static |
String container for deferring output of startup errors.
Definition at line 153 of file loader.c.
Referenced by load_modules(), and module_load_error().
const char* support_level_map[] |
Definition at line 2918 of file loader.c.
Referenced by ast_module_support_level_to_string().