summaryrefslogtreecommitdiff
path: root/main/dnsmgr.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2018-02-16 22:11:42 -0500
committerCorey Farrell <git@cfware.com>2018-03-14 05:20:12 -0400
commit572a508ef2ae7cd86e0ffd8ad6d1c5997e988c26 (patch)
treea0dcfa18f8a4a9d3e87eac3b2a7df33ac2fbcad6 /main/dnsmgr.c
parentfee929c8acd788a77982b537953bf4053242057e (diff)
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
Diffstat (limited to 'main/dnsmgr.c')
-rw-r--r--main/dnsmgr.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/main/dnsmgr.c b/main/dnsmgr.c
index 0e5efd6da..c25b601b3 100644
--- a/main/dnsmgr.c
+++ b/main/dnsmgr.c
@@ -49,6 +49,7 @@
#include <regex.h>
#include <signal.h>
+#include "asterisk/module.h"
#include "asterisk/dnsmgr.h"
#include "asterisk/linkedlists.h"
#include "asterisk/utils.h"
@@ -406,7 +407,7 @@ static struct ast_cli_entry cli_reload = AST_CLI_DEFINE(handle_cli_reload, "Relo
static struct ast_cli_entry cli_refresh = AST_CLI_DEFINE(handle_cli_refresh, "Performs an immediate refresh");
static struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the DNS manager status");
-static void dnsmgr_shutdown(void)
+static int unload_module(void)
{
ast_cli_unregister(&cli_reload);
ast_cli_unregister(&cli_status);
@@ -424,24 +425,24 @@ static void dnsmgr_shutdown(void)
ast_mutex_unlock(&refresh_lock);
ast_sched_context_destroy(sched);
+
+ return 0;
}
-int dnsmgr_init(void)
+static int load_module(void)
{
if (!(sched = ast_sched_context_create())) {
ast_log(LOG_ERROR, "Unable to create schedule context.\n");
- return -1;
+ return AST_MODULE_LOAD_FAILURE;
}
ast_cli_register(&cli_reload);
ast_cli_register(&cli_status);
ast_cli_register(&cli_refresh);
- ast_register_cleanup(dnsmgr_shutdown);
-
- return do_reload(1);
+ return do_reload(1) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
}
-int dnsmgr_reload(void)
+static int reload_module(void)
{
return do_reload(0);
}
@@ -515,3 +516,11 @@ static int do_reload(int loading)
return 0;
}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "DNS Manager",
+ .support_level = AST_MODULE_SUPPORT_CORE,
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload_module,
+ .load_pri = AST_MODPRI_CORE,
+);