loader: Convert reload_classes to built-in modules.

* acl (named_acl.c)
* cdr
* cel
* ccss
* dnsmgr
* dsp
* enum
* extconfig (config.c)
* features
* http
* indications
* logger
* manager
* plc
* sounds
* udptl

These modules are now loaded at appropriate time by the module loader.
Unlike loadable modules these use AST_MODULE_LOAD_FAILURE on error so
the module loader will abort startup on failure of these modules.

Some of these modules are still initialized or shutdown from outside the
module loader.  logger.c is initialized very early and shutdown very
late, manager.c is initialized by the module loader but is shutdown by
the Asterisk core (too much uses it without holding references).

Change-Id: I371a9a45064f20026c492623ea8062d02a1ab97f
This commit is contained in:
Corey Farrell
2018-02-16 22:11:42 -05:00
parent fee929c8ac
commit 572a508ef2
79 changed files with 526 additions and 423 deletions

View File

@@ -38,7 +38,7 @@
#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
@@ -1421,7 +1421,7 @@ static void destroy_subscriptions(void)
cel_cel_forwarder = stasis_forward_cancel(cel_cel_forwarder);
}
static void cel_engine_cleanup(void)
static int unload_module(void)
{
destroy_routes();
destroy_subscriptions();
@@ -1433,6 +1433,8 @@ static void cel_engine_cleanup(void)
ao2_global_obj_release(cel_dialstatus_store);
ao2_global_obj_release(cel_linkedids);
ao2_global_obj_release(cel_backends);
return 0;
}
/*!
@@ -1555,7 +1557,7 @@ static int create_routes(void)
AO2_STRING_FIELD_HASH_FN(cel_linkedid, id)
AO2_STRING_FIELD_CMP_FN(cel_linkedid, id)
int ast_cel_engine_init(void)
static int load_module(void)
{
struct ao2_container *container;
@@ -1563,7 +1565,7 @@ int ast_cel_engine_init(void)
ao2_global_obj_replace_unref(cel_linkedids, container);
ao2_cleanup(container);
if (!container) {
return -1;
return AST_MODULE_LOAD_FAILURE;
}
container = ao2_container_alloc(NUM_DIALSTATUS_BUCKETS,
@@ -1571,26 +1573,26 @@ int ast_cel_engine_init(void)
ao2_global_obj_replace_unref(cel_dialstatus_store, container);
ao2_cleanup(container);
if (!container) {
return -1;
return AST_MODULE_LOAD_FAILURE;
}
if (STASIS_MESSAGE_TYPE_INIT(cel_generic_type)) {
return -1;
return AST_MODULE_LOAD_FAILURE;
}
if (ast_cli_register(&cli_status)) {
return -1;
return AST_MODULE_LOAD_FAILURE;
}
container = ao2_container_alloc(BACKEND_BUCKETS, cel_backend_hash_fn, cel_backend_cmp_fn);
ao2_global_obj_replace_unref(cel_backends, container);
ao2_cleanup(container);
if (!container) {
return -1;
return AST_MODULE_LOAD_FAILURE;
}
if (aco_info_init(&cel_cfg_info)) {
return -1;
return AST_MODULE_LOAD_FAILURE;
}
aco_option_register(&cel_cfg_info, "enable", ACO_EXACT, general_options, "no", OPT_BOOL_T, 1, FLDSET(struct ast_cel_general_config, enable));
@@ -1602,7 +1604,7 @@ int ast_cel_engine_init(void)
struct cel_config *cel_cfg = cel_config_alloc();
if (!cel_cfg) {
return -1;
return AST_MODULE_LOAD_FAILURE;
}
/* We couldn't process the configuration so create a default config. */
@@ -1614,18 +1616,17 @@ int ast_cel_engine_init(void)
}
if (create_subscriptions()) {
return -1;
return AST_MODULE_LOAD_FAILURE;
}
if (ast_cel_check_enabled() && create_routes()) {
return -1;
return AST_MODULE_LOAD_FAILURE;
}
ast_register_cleanup(cel_engine_cleanup);
return 0;
return AST_MODULE_LOAD_SUCCESS;
}
int ast_cel_engine_reload(void)
static int reload_module(void)
{
unsigned int was_enabled = ast_cel_check_enabled();
unsigned int is_enabled;
@@ -1745,3 +1746,11 @@ int ast_cel_backend_register(const char *name, ast_cel_backend_cb backend_callba
ao2_ref(backend, -1);
return 0;
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "CEL Engine",
.support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
.reload = reload_module,
.load_pri = AST_MODPRI_CORE,
);