[Asterisk-code-review] loader: Convert reload classes to built-in modules. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Sat Feb 24 00:27:27 CST 2018


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/8390


Change subject: loader: Convert reload_classes to built-in modules.
......................................................................

loader: Convert reload_classes to built-in modules.

* acl (named_acl.c)
* cdr
* cel
* 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
---
M addons/cdr_mysql.c
M addons/chan_ooh323.c
M addons/res_config_mysql.c
M apps/app_celgenuserevent.c
M apps/app_forkcdr.c
M cdr/cdr_adaptive_odbc.c
M cdr/cdr_beanstalkd.c
M cdr/cdr_csv.c
M cdr/cdr_custom.c
M cdr/cdr_manager.c
M cdr/cdr_odbc.c
M cdr/cdr_pgsql.c
M cdr/cdr_radius.c
M cdr/cdr_sqlite.c
M cdr/cdr_sqlite3_custom.c
M cdr/cdr_syslog.c
M cdr/cdr_tds.c
M cel/cel_beanstalkd.c
M cel/cel_custom.c
M cel/cel_manager.c
M cel/cel_odbc.c
M cel/cel_pgsql.c
M cel/cel_radius.c
M cel/cel_sqlite3_custom.c
M cel/cel_tds.c
M channels/chan_iax2.c
M channels/chan_sip.c
M funcs/func_cdr.c
M funcs/func_enum.c
M include/asterisk/_private.h
M include/asterisk/acl.h
M include/asterisk/cdr.h
M include/asterisk/config.h
M include/asterisk/dsp.h
M include/asterisk/enum.h
M include/asterisk/features_config.h
M include/asterisk/logger.h
M include/asterisk/manager.h
M include/asterisk/module.h
M include/asterisk/sounds_index.h
M include/asterisk/udptl.h
M main/Makefile
M main/asterisk.c
M main/cdr.c
M main/cel.c
M main/channel.c
M main/config.c
M main/dnsmgr.c
M main/dsp.c
M main/enum.c
M main/features.c
M main/features_config.c
A main/features_config.h
M main/http.c
M main/indications.c
M main/loader.c
M main/logger.c
M main/manager.c
M main/named_acl.c
M main/plc.c
M main/sounds.c
M main/udptl.c
M res/res_ari.c
M res/res_config_curl.c
M res/res_config_ldap.c
M res/res_config_odbc.c
M res/res_config_pgsql.c
M res/res_config_sqlite.c
M res/res_config_sqlite3.c
M res/res_http_post.c
M res/res_http_websocket.c
M res/res_phoneprov.c
M res/res_pjsip.c
M res/res_pjsip_t38.c
74 files changed, 472 insertions(+), 407 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/90/8390/1

diff --git a/addons/cdr_mysql.c b/addons/cdr_mysql.c
index 00c75dd..2fefe4e 100644
--- a/addons/cdr_mysql.c
+++ b/addons/cdr_mysql.c
@@ -724,4 +724,5 @@
 	.load = load_module,
 	.unload = unload_module,
 	.reload = reload,
+	.requires = "cdr",
 );
diff --git a/addons/chan_ooh323.c b/addons/chan_ooh323.c
index 8c4ff2c..81c88d1 100644
--- a/addons/chan_ooh323.c
+++ b/addons/chan_ooh323.c
@@ -5244,5 +5244,6 @@
 	.load = load_module,
 	.unload = unload_module,
 	.reload = reload_module,
-	.load_pri = AST_MODPRI_CHANNEL_DRIVER
+	.load_pri = AST_MODPRI_CHANNEL_DRIVER,
+	.requires = "udptl",
 );
diff --git a/addons/res_config_mysql.c b/addons/res_config_mysql.c
index ae43485..edd9385 100644
--- a/addons/res_config_mysql.c
+++ b/addons/res_config_mysql.c
@@ -1559,4 +1559,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_REALTIME_DRIVER,
+	.requires = "extconfig",
 );
diff --git a/apps/app_celgenuserevent.c b/apps/app_celgenuserevent.c
index 67c7fbc..11b11b0 100644
--- a/apps/app_celgenuserevent.c
+++ b/apps/app_celgenuserevent.c
@@ -103,4 +103,5 @@
 	.support_level = AST_MODULE_SUPPORT_CORE,
 	.load = load_module,
 	.unload = unload_module,
+	.requires = "cel",
 );
diff --git a/apps/app_forkcdr.c b/apps/app_forkcdr.c
index 73963f3..25b56cb 100644
--- a/apps/app_forkcdr.c
+++ b/apps/app_forkcdr.c
@@ -215,4 +215,9 @@
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Fork The CDR into 2 separate entities");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Fork The CDR into 2 separate entities",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.requires = "cdr",
+);
diff --git a/cdr/cdr_adaptive_odbc.c b/cdr/cdr_adaptive_odbc.c
index d4da850..2829130 100644
--- a/cdr/cdr_adaptive_odbc.c
+++ b/cdr/cdr_adaptive_odbc.c
@@ -830,4 +830,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr,res_odbc",
 );
diff --git a/cdr/cdr_beanstalkd.c b/cdr/cdr_beanstalkd.c
index 8f4863a..524274f 100644
--- a/cdr/cdr_beanstalkd.c
+++ b/cdr/cdr_beanstalkd.c
@@ -261,9 +261,10 @@
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Asterisk Beanstalkd CDR Backend",
-.support_level = AST_MODULE_SUPPORT_EXTENDED,
-.load = load_module,
-.unload = unload_module,
-.reload = reload,
-.load_pri = AST_MODPRI_CDR_DRIVER,
+	.support_level = AST_MODULE_SUPPORT_EXTENDED,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload,
+	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr",
 );
diff --git a/cdr/cdr_csv.c b/cdr/cdr_csv.c
index 5666a3d..e4c74ff 100644
--- a/cdr/cdr_csv.c
+++ b/cdr/cdr_csv.c
@@ -360,4 +360,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr",
 );
diff --git a/cdr/cdr_custom.c b/cdr/cdr_custom.c
index 5a5eb9e..72a475c 100644
--- a/cdr/cdr_custom.c
+++ b/cdr/cdr_custom.c
@@ -231,4 +231,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr",
 );
diff --git a/cdr/cdr_manager.c b/cdr/cdr_manager.c
index 3f0cc6b..74f37d2 100644
--- a/cdr/cdr_manager.c
+++ b/cdr/cdr_manager.c
@@ -371,4 +371,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr",
 );
diff --git a/cdr/cdr_odbc.c b/cdr/cdr_odbc.c
index b44bbf5..e555c68 100644
--- a/cdr/cdr_odbc.c
+++ b/cdr/cdr_odbc.c
@@ -327,4 +327,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr",
 );
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index b482fe6..8ffaa79 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -794,4 +794,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr",
 );
diff --git a/cdr/cdr_radius.c b/cdr/cdr_radius.c
index a43e96c..0a5fa63 100644
--- a/cdr/cdr_radius.c
+++ b/cdr/cdr_radius.c
@@ -287,4 +287,5 @@
 	.load = load_module,
 	.unload = unload_module,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr",
 );
diff --git a/cdr/cdr_sqlite.c b/cdr/cdr_sqlite.c
index b912960..aceff0f 100644
--- a/cdr/cdr_sqlite.c
+++ b/cdr/cdr_sqlite.c
@@ -248,4 +248,5 @@
 	.load = load_module,
 	.unload = unload_module,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr",
 );
diff --git a/cdr/cdr_sqlite3_custom.c b/cdr/cdr_sqlite3_custom.c
index 2212d04..9f71c84 100644
--- a/cdr/cdr_sqlite3_custom.c
+++ b/cdr/cdr_sqlite3_custom.c
@@ -360,4 +360,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr",
 );
diff --git a/cdr/cdr_syslog.c b/cdr/cdr_syslog.c
index bbc4406..4f0a78c 100644
--- a/cdr/cdr_syslog.c
+++ b/cdr/cdr_syslog.c
@@ -292,4 +292,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr",
 );
diff --git a/cdr/cdr_tds.c b/cdr/cdr_tds.c
index f3d0628..2de4e42 100644
--- a/cdr/cdr_tds.c
+++ b/cdr/cdr_tds.c
@@ -635,4 +635,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cdr",
 );
diff --git a/cel/cel_beanstalkd.c b/cel/cel_beanstalkd.c
index e6f2380..fe4f430 100644
--- a/cel/cel_beanstalkd.c
+++ b/cel/cel_beanstalkd.c
@@ -272,4 +272,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cel",
 );
diff --git a/cel/cel_custom.c b/cel/cel_custom.c
index 9c81ee1..73423a3 100644
--- a/cel/cel_custom.c
+++ b/cel/cel_custom.c
@@ -223,4 +223,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cel",
 );
diff --git a/cel/cel_manager.c b/cel/cel_manager.c
index 365bb70..e485aab 100644
--- a/cel/cel_manager.c
+++ b/cel/cel_manager.c
@@ -380,4 +380,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cel",
 );
diff --git a/cel/cel_odbc.c b/cel/cel_odbc.c
index 05c1095..e4cd2d2 100644
--- a/cel/cel_odbc.c
+++ b/cel/cel_odbc.c
@@ -855,4 +855,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cel,res_odbc",
 );
diff --git a/cel/cel_pgsql.c b/cel/cel_pgsql.c
index 5fe6678..f013cc7 100644
--- a/cel/cel_pgsql.c
+++ b/cel/cel_pgsql.c
@@ -709,4 +709,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cel",
 );
diff --git a/cel/cel_radius.c b/cel/cel_radius.c
index 250d6a7..4e87f86 100644
--- a/cel/cel_radius.c
+++ b/cel/cel_radius.c
@@ -259,4 +259,5 @@
 	.load = load_module,
 	.unload = unload_module,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cel",
 );
diff --git a/cel/cel_sqlite3_custom.c b/cel/cel_sqlite3_custom.c
index 5675da6..db38eaf 100644
--- a/cel/cel_sqlite3_custom.c
+++ b/cel/cel_sqlite3_custom.c
@@ -360,4 +360,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cel",
 );
diff --git a/cel/cel_tds.c b/cel/cel_tds.c
index 0859fab..0aa73e5 100644
--- a/cel/cel_tds.c
+++ b/cel/cel_tds.c
@@ -580,4 +580,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CDR_DRIVER,
+	.requires = "cel",
 );
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index eade5d1..dec9dfd 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -14902,5 +14902,6 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CHANNEL_DRIVER,
+	.requires = "dnsmgr",
 	.optional_modules = "res_crypto",
 );
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index acf5a14..c074479 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -35737,5 +35737,6 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CHANNEL_DRIVER,
+	.requires = "dnsmgr,udptl",
 	.optional_modules = "res_crypto,res_http_websocket",
 );
diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c
index 2dd9f15..d7bc211 100644
--- a/funcs/func_cdr.c
+++ b/funcs/func_cdr.c
@@ -704,4 +704,9 @@
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call Detail Record (CDR) dialplan functions");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Call Detail Record (CDR) dialplan functions",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.requires = "cdr",
+);
diff --git a/funcs/func_enum.c b/funcs/func_enum.c
index 6929e3c..f649e0f 100644
--- a/funcs/func_enum.c
+++ b/funcs/func_enum.c
@@ -472,4 +472,9 @@
 	return res;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "ENUM related dialplan functions");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "ENUM related dialplan functions",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.requires = "enum",
+);
diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h
index e989b16..72964e6 100644
--- a/include/asterisk/_private.h
+++ b/include/asterisk/_private.h
@@ -33,26 +33,17 @@
 int ast_channels_init(void);		/*!< Provided by channel.c */
 void ast_builtins_init(void);		/*!< Provided by cli.c */
 int ast_cli_perms_init(int reload);	/*!< Provided by cli.c */
-int dnsmgr_init(void);			/*!< Provided by dnsmgr.c */
 void dnsmgr_start_refresh(void);	/*!< Provided by dnsmgr.c */
-int dnsmgr_reload(void);		/*!< Provided by dnsmgr.c */
 int ast_dns_system_resolver_init(void); /*!< Provided by dns_system_resolver.c */
 void threadstorage_init(void);		/*!< Provided by threadstorage.c */
 int ast_device_state_engine_init(void);	/*!< Provided by devicestate.c */
 int astobj2_init(void);			/*!< Provided by astobj2.c */
 int ast_named_locks_init(void);		/*!< Provided by named_locks.c */
 int ast_file_init(void);		/*!< Provided by file.c */
-int ast_features_init(void);            /*!< Provided by features.c */
 void ast_autoservice_init(void);	/*!< Provided by autoservice.c */
-int ast_http_init(void);		/*!< Provided by http.c */
-int ast_http_reload(void);		/*!< Provided by http.c */
 int ast_tps_init(void); 		/*!< Provided by taskprocessor.c */
 int ast_timing_init(void);		/*!< Provided by timing.c */
-int ast_indications_init(void); /*!< Provided by indications.c */
-int ast_indications_reload(void);/*!< Provided by indications.c */
 void ast_stun_init(void);               /*!< Provided by stun.c */
-int ast_cel_engine_init(void);		/*!< Provided by cel.c */
-int ast_cel_engine_reload(void);	/*!< Provided by cel.c */
 int ast_ssl_init(void);                 /*!< Provided by ssl.c */
 int ast_pj_init(void);                 /*!< Provided by libasteriskpj.c */
 int ast_test_init(void);            /*!< Provided by test.c */
@@ -96,13 +87,6 @@
  */
 int ast_xmldoc_load_documentation(void);
 
-/*!
- * \brief Reload genericplc configuration value from codecs.conf
- *
- * Implementation is in main/channel.c
- */
-int ast_plc_reload(void);
-
 /*! \brief initializes the rtp engine arrays */
 int ast_rtp_engine_init(void);
 
@@ -111,9 +95,6 @@
  * \since 12.0.0
  */
 int ast_parking_stasis_init(void);
-
-/*! \brief initialize the sounds index */
-int ast_sounds_index_init(void);
 
 /*!
  * \brief Endpoint support initialization.
diff --git a/include/asterisk/acl.h b/include/asterisk/acl.h
index bda1c76..09adc52 100644
--- a/include/asterisk/acl.h
+++ b/include/asterisk/acl.h
@@ -382,24 +382,6 @@
 struct ast_ha *ast_named_acl_find(const char *name, int *is_realtime, int *is_undefined);
 
 /*!
- * \brief Initialize and configure the named ACL system.
- *
- * \details
- * This function will prepare the named ACL system for use.
- * For this reason, it needs to be called before other things that use ACLs are initialized.
- */
-int ast_named_acl_init(void);
-
-/*!
- * \brief reload/reconfigure the named ACL system.
- *
- * \details
- * This function is designed to trigger an event upon a successful reload that may update
- * ACL consumers.
- */
-int ast_named_acl_reload(void);
-
-/*!
  * \brief a \ref stasis_message_type for changes against a named ACL or the set of all named ACLs
  * \since 12
  *
diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h
index e10da82..c6b2413 100644
--- a/include/asterisk/cdr.h
+++ b/include/asterisk/cdr.h
@@ -581,12 +581,6 @@
  */
 void ast_cdr_setuserfield(const char *channel_name, const char *userfield);
 
-/*! \brief Reload the configuration file cdr.conf and start/stop CDR scheduling thread */
-int ast_cdr_engine_reload(void);
-
-/*! \brief Load the configuration file cdr.conf and possibly start the CDR scheduling thread */
-int ast_cdr_engine_init(void);
-
 /*! Submit any remaining CDRs and prepare for shutdown */
 void ast_cdr_engine_term(void);
 
diff --git a/include/asterisk/config.h b/include/asterisk/config.h
index fd9641e..a7b144e 100644
--- a/include/asterisk/config.h
+++ b/include/asterisk/config.h
@@ -784,15 +784,6 @@
  */
 int register_config_cli(void);
 
-/*!
- * \brief Exposed re-initialization method for core process
- *
- * \details
- * This method is intended for use only with the core re-initialization and is
- * not designed to be called from any user applications.
- */
-int read_config_maps(void);
-
 /*! \brief Create a new base configuration structure */
 struct ast_config *ast_config_new(void);
 
diff --git a/include/asterisk/dsp.h b/include/asterisk/dsp.h
index d092e6b..769d3b9 100644
--- a/include/asterisk/dsp.h
+++ b/include/asterisk/dsp.h
@@ -193,16 +193,4 @@
  */
 int ast_dsp_get_threshold_from_settings(enum threshold which);
 
-/*!
- * \brief Reloads dsp settings from dsp.conf
- * \since 1.6.1
- */
-int ast_dsp_reload(void);
-
-/*!
- * \brief Load dsp settings from dsp.conf
- * \since 1.6.1
- */
-int ast_dsp_init(void);
-
 #endif /* _ASTERISK_DSP_H */
diff --git a/include/asterisk/enum.h b/include/asterisk/enum.h
index 877c0c3..2ce85cc 100644
--- a/include/asterisk/enum.h
+++ b/include/asterisk/enum.h
@@ -97,7 +97,4 @@
  */
 int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int maxtxt, char *suffix);
 
-int ast_enum_init(void);
-int ast_enum_reload(void);
-
 #endif /* _ASTERISK_ENUM_H */
diff --git a/include/asterisk/features_config.h b/include/asterisk/features_config.h
index 1bce50b..cd1bbbc 100644
--- a/include/asterisk/features_config.h
+++ b/include/asterisk/features_config.h
@@ -265,10 +265,4 @@
  */
 struct ao2_container *ast_get_chan_applicationmap(struct ast_channel *chan);
 
-void ast_features_config_shutdown(void);
-
-int ast_features_config_reload(void);
-
-int ast_features_config_init(void);
-
 #endif /* _FEATURES_CONFIG_H */
diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h
index 8b1e5fe..df03931 100644
--- a/include/asterisk/logger.h
+++ b/include/asterisk/logger.h
@@ -133,9 +133,6 @@
  */
 void ast_log_backtrace(void);
 
-/*! \brief Reload logger without rotating log files */
-int logger_reload(void);
-
 /*! \brief Reload logger while rotating log files */
 int ast_logger_rotate(void);
 
diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h
index 35dc227..97d4b9c 100644
--- a/include/asterisk/manager.h
+++ b/include/asterisk/manager.h
@@ -356,12 +356,6 @@
 /*! \brief Determinie if a manager session ident is authenticated */
 int astman_is_authed(uint32_t ident);
 
-/*! \brief Called by Asterisk initialization */
-int init_manager(void);
-
-/*! \brief Called by Asterisk module functions and the CLI command */
-int reload_manager(void);
-
 /*!
  * \brief Add a datastore to a session
  *
diff --git a/include/asterisk/module.h b/include/asterisk/module.h
index ebd41c0..2ba7e2c 100644
--- a/include/asterisk/module.h
+++ b/include/asterisk/module.h
@@ -292,6 +292,7 @@
 	AST_MODPRI_REALTIME_DEPEND =    10,  /*!< Dependency for a realtime driver */
 	AST_MODPRI_REALTIME_DEPEND2 =   20,  /*!< Second level dependency for a realtime driver (func_curl needs res_curl, but is needed by res_config_curl) */
 	AST_MODPRI_REALTIME_DRIVER =    30,  /*!< A realtime driver, which provides configuration services for other modules */
+	AST_MODPRI_CORE =               40,  /*!< A core module originally meant to start between preload and load. */
 	AST_MODPRI_TIMING =             40,  /*!< Dependency for a channel (MOH needs timing interfaces to be fully loaded) */
 	AST_MODPRI_CHANNEL_DEPEND =     50,  /*!< Channel driver dependency (may depend upon realtime, e.g. MOH) */
 	AST_MODPRI_CHANNEL_DRIVER =     60,  /*!< Channel drivers (provide devicestate) */
diff --git a/include/asterisk/sounds_index.h b/include/asterisk/sounds_index.h
index d7eb053..bbd3965 100644
--- a/include/asterisk/sounds_index.h
+++ b/include/asterisk/sounds_index.h
@@ -33,14 +33,6 @@
 struct ast_media_index;
 
 /*!
- * \brief Reload the sounds index
- *
- * \retval zero on success
- * \retval non-zero on failure
- */
-int ast_sounds_reindex(void);
-
-/*!
  * \brief Get the sounds index
  *
  * \retval sounds index (must be ao2_cleanup()'ed)
diff --git a/include/asterisk/udptl.h b/include/asterisk/udptl.h
index 7137ff9..0d79d6f 100644
--- a/include/asterisk/udptl.h
+++ b/include/asterisk/udptl.h
@@ -126,13 +126,6 @@
 
 void ast_udptl_stop(struct ast_udptl *udptl);
 
-void ast_udptl_init(void);
-
-/*!
- * \version 1.6.1 return changed to int
- */
-int ast_udptl_reload(void);
-
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif
diff --git a/main/Makefile b/main/Makefile
index ba7491d..e7dab98 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -17,9 +17,9 @@
 
 include $(ASTTOPDIR)/Makefile.moddir_rules
 
-# Can the MODSRC list be automated without needing built-in modules to be
-# in a different directory?  Would a different directory be better?
-MOD_SRC:=
+MOD_SRC:=cdr.c cel.c config.c dnsmgr.c dsp.c enum.c features.c http.c indications.c logger.c manager.c named_acl.c plc.c sounds.c udptl.c
+# Allow deletion of built-in modules without needing to modify this source.
+MOD_SRC:=$(wildcard $(MOD_SRC))
 MOD_OBJS:=$(sort $(MOD_SRC:.c=.o))
 
 # Must include the extra ast_expr2.c, ast_expr2f.c, in case they need to be regenerated (because to force regeneration, we delete them)
diff --git a/main/asterisk.c b/main/asterisk.c
index 4c15d23..ab90fd4 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -199,7 +199,6 @@
 #include "asterisk/channel.h"
 #include "asterisk/translate.h"
 #include "asterisk/pickup.h"
-#include "asterisk/features.h"
 #include "asterisk/acl.h"
 #include "asterisk/ulaw.h"
 #include "asterisk/alaw.h"
@@ -209,11 +208,7 @@
 #include "asterisk/term.h"
 #include "asterisk/manager.h"
 #include "asterisk/cdr.h"
-#include "asterisk/cel.h"
 #include "asterisk/pbx.h"
-#include "asterisk/enum.h"
-#include "asterisk/http.h"
-#include "asterisk/udptl.h"
 #include "asterisk/app.h"
 #include "asterisk/lock.h"
 #include "asterisk/utils.h"
@@ -225,7 +220,6 @@
 #include "asterisk/devicestate.h"
 #include "asterisk/presencestate.h"
 #include "asterisk/module.h"
-#include "asterisk/dsp.h"
 #include "asterisk/buildinfo.h"
 #include "asterisk/xmldoc.h"
 #include "asterisk/poll-compat.h"
@@ -4441,12 +4435,7 @@
 
 	print_intro_message(runuser, rungroup);
 
-	if (ast_opt_console) {
-		ast_verb(0, "[ Initializing Custom Configuration Options ]\n");
-	}
-	/* custom config setup */
 	register_config_cli();
-	read_config_maps();
 
 	check_init(astobj2_init(), "AO2");
 	check_init(ast_named_locks_init(), "Named Locks");
@@ -4556,34 +4545,13 @@
 	check_init(load_pbx_app(), "PBX Application Support");
 	check_init(load_pbx_hangup_handler(), "PBX Hangup Handler Support");
 	check_init(ast_local_init(), "Local Proxy Channel Driver");
+	check_init(ast_cc_init(), "Call Completion Supplementary Services");
 
 	/* We should avoid most config loads before this point as they can't use realtime. */
 	check_init(load_modules(1), "Module Preload");
 
-	/* Initialize core modules that have config files.  These should be converted to
-	 * built-in modules with load priority after realtime, that way users will not
-	 * need to 'preload' realtime modules. */
-	check_init(ast_features_init(), "Call Features");
-	check_init(dnsmgr_init(), "DNS manager");
-	check_init(ast_named_acl_init(), "Named ACL system");
-	ast_http_init();
-	check_init(ast_indications_init(), "Indication Tone Handling");
-	check_init(ast_cdr_engine_init(), "CDR Engine");
-	ast_dsp_init();
-	ast_udptl_init();
-	check_init(ast_cel_engine_init(), "CEL Engine");
-	check_init(init_manager(), "Asterisk Manager Interface");
-	check_init(ast_enum_init(), "ENUM Support");
-	check_init(ast_cc_init(), "Call Completion Supplementary Services");
-
 	/* Load remaining modules */
 	check_init(load_modules(0), "Module");
-
-	/*
-	 * This is initialized after the dynamic modules load to avoid repeatedly
-	 * reindexing sounds for every format module load.
-	 */
-	check_init(ast_sounds_index_init(), "Sounds Indexer");
 
 	/*
 	 * This has to load after the dynamic modules load, as items in the media
diff --git a/main/cdr.c b/main/cdr.c
index 4acadf9..462e9c1 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -53,6 +53,7 @@
 #include "asterisk/cdr.h"
 #include "asterisk/callerid.h"
 #include "asterisk/manager.h"
+#include "asterisk/module.h"
 #include "asterisk/causes.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/utils.h"
@@ -4366,11 +4367,6 @@
 	return 0;
 }
 
-static void cdr_engine_cleanup(void)
-{
-	destroy_subscriptions();
-}
-
 static void cdr_engine_shutdown(void)
 {
 	stasis_message_router_unsubscribe_and_join(stasis_router);
@@ -4503,26 +4499,33 @@
 	return mod_cfg ? 0 : -1;
 }
 
-int ast_cdr_engine_init(void)
+static int unload_module(void)
+{
+	destroy_subscriptions();
+
+	return 0;
+}
+
+static int load_module(void)
 {
 	if (process_config(0)) {
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	cdr_topic = stasis_topic_create("cdr_engine");
 	if (!cdr_topic) {
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	stasis_router = stasis_message_router_create(cdr_topic);
 	if (!stasis_router) {
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 	stasis_message_router_set_congestion_limits(stasis_router, -1,
 		10 * AST_TASKPROCESSOR_HIGH_WATER_LEVEL);
 
 	if (STASIS_MESSAGE_TYPE_INIT(cdr_sync_message_type)) {
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	stasis_message_router_add_cache_update(stasis_router, ast_channel_snapshot_type(), handle_channel_cache_message, NULL);
@@ -4535,28 +4538,27 @@
 	active_cdrs_master = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,
 		NUM_CDR_BUCKETS, cdr_master_hash_fn, NULL, cdr_master_cmp_fn);
 	if (!active_cdrs_master) {
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 	ao2_container_register("cdrs_master", active_cdrs_master, cdr_master_print_fn);
 
 	active_cdrs_all = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,
 		NUM_CDR_BUCKETS, cdr_all_hash_fn, NULL, cdr_all_cmp_fn);
 	if (!active_cdrs_all) {
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 	ao2_container_register("cdrs_all", active_cdrs_all, cdr_all_print_fn);
 
 	sched = ast_sched_context_create();
 	if (!sched) {
 		ast_log(LOG_ERROR, "Unable to create schedule context.\n");
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands));
-	ast_register_cleanup(cdr_engine_cleanup);
 	ast_register_atexit(cdr_engine_shutdown);
 
-	return cdr_toggle_runtime_options();
+	return cdr_toggle_runtime_options() ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
 }
 
 void ast_cdr_engine_term(void)
@@ -4599,7 +4601,7 @@
 	}
 }
 
-int ast_cdr_engine_reload(void)
+static int reload_module(void)
 {
 	struct module_config *old_mod_cfg;
 	struct module_config *mod_cfg;
@@ -4625,3 +4627,11 @@
 	ao2_cleanup(old_mod_cfg);
 	return cdr_toggle_runtime_options();
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "CDR Engine",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.load_pri = AST_MODPRI_CORE,
+);
diff --git a/main/cel.c b/main/cel.c
index e4fae6d..91c625a 100644
--- a/main/cel.c
+++ b/main/cel.c
@@ -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 @@
 	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 @@
 	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 @@
 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,8 +1565,7 @@
 	ao2_global_obj_replace_unref(cel_linkedids, container);
 	ao2_cleanup(container);
 	if (!container) {
-		cel_engine_cleanup();
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	container = ao2_container_alloc(NUM_DIALSTATUS_BUCKETS,
@@ -1572,31 +1573,26 @@
 	ao2_global_obj_replace_unref(cel_dialstatus_store, container);
 	ao2_cleanup(container);
 	if (!container) {
-		cel_engine_cleanup();
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	if (STASIS_MESSAGE_TYPE_INIT(cel_generic_type)) {
-		cel_engine_cleanup();
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	if (ast_cli_register(&cli_status)) {
-		cel_engine_cleanup();
-		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) {
-		cel_engine_cleanup();
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	if (aco_info_init(&cel_cfg_info)) {
-		cel_engine_cleanup();
-		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));
@@ -1608,8 +1604,7 @@
 		struct cel_config *cel_cfg = cel_config_alloc();
 
 		if (!cel_cfg) {
-			cel_engine_cleanup();
-			return -1;
+			return AST_MODULE_LOAD_FAILURE;
 		}
 
 		/* We couldn't process the configuration so create a default config. */
@@ -1621,20 +1616,17 @@
 	}
 
 	if (create_subscriptions()) {
-		cel_engine_cleanup();
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	if (ast_cel_check_enabled() && create_routes()) {
-		cel_engine_cleanup();
-		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;
@@ -1754,3 +1746,11 @@
 	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,
+);
diff --git a/main/channel.c b/main/channel.c
index c71d19b..ebd39c7 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -7583,22 +7583,6 @@
 	return ast_str_case_hash(name);
 }
 
-int ast_plc_reload(void)
-{
-	struct ast_variable *var;
-	struct ast_flags config_flags = { 0 };
-	struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
-	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
-		return 0;
-	for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
-		if (!strcasecmp(var->name, "genericplc")) {
-			ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC);
-		}
-	}
-	ast_config_destroy(cfg);
-	return 0;
-}
-
 /*!
  * \internal
  * \brief Print channel object key (name).
@@ -7821,8 +7805,6 @@
 	ast_stasis_channels_init();
 
 	ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel));
-
-	ast_plc_reload();
 
 	ast_register_cleanup(channels_shutdown);
 
diff --git a/main/config.c b/main/config.c
index 118b958..24e9fcc 100644
--- a/main/config.c
+++ b/main/config.c
@@ -30,6 +30,11 @@
 	<support_level>core</support_level>
  ***/
 
+/* This maintains the original "module reload extconfig" CLI command instead
+ * of replacing it with "module reload config". */
+#undef AST_MODULE
+#define AST_MODULE "extconfig"
+
 #include "asterisk.h"
 
 #include "asterisk/paths.h"	/* use ast_config_AST_CONFIG_DIR */
@@ -54,6 +59,7 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/strings.h"	/* for the ast_str_*() API */
 #include "asterisk/netsock2.h"
+#include "asterisk/module.h"
 
 #define MAX_NESTED_COMMENTS 128
 #define COMMENT_START ";--"
@@ -2885,7 +2891,7 @@
 	return 0;
 }
 
-int read_config_maps(void)
+static int reload_module(void)
 {
 	struct ast_config *config, *configtmp;
 	struct ast_variable *v;
@@ -4044,6 +4050,7 @@
 int register_config_cli(void)
 {
 	ast_cli_register_multiple(cli_config, ARRAY_LEN(cli_config));
+	/* This is separate from the module load so cleanup can happen very late. */
 	ast_register_cleanup(config_shutdown);
 	return 0;
 }
@@ -4130,3 +4137,26 @@
 	ao2_ref(hook, -1);
 	return 0;
 }
+
+static int unload_module(void)
+{
+	return 0;
+}
+
+static int load_module(void)
+{
+	if (ast_opt_console) {
+		ast_verb(0, "[ Initializing Custom Configuration Options ]\n");
+	}
+
+	return reload_module() ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
+}
+
+/* This module explicitly loads before realtime drivers. */
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Configuration",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.load_pri = 0,
+);
diff --git a/main/dnsmgr.c b/main/dnsmgr.c
index 0e5efd6..c25b601 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_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 @@
 	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 @@
 
 	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,
+);
diff --git a/main/dsp.c b/main/dsp.c
index 8b39fe5..f048d1b 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -57,6 +57,7 @@
 
 #include <math.h>
 
+#include "asterisk/module.h"
 #include "asterisk/frame.h"
 #include "asterisk/format_cache.h"
 #include "asterisk/channel.h"
@@ -1331,10 +1332,11 @@
 #ifndef BUSYDETECT_TONEONLY
 	if ((hittone >= dsp->busycount - 1) && (hitsilence >= dsp->busycount - 1) &&
 	    (avgtone >= BUSY_MIN && avgtone <= BUSY_MAX) &&
-	    (avgsilence >= BUSY_MIN && avgsilence <= BUSY_MAX)) {
+	    (avgsilence >= BUSY_MIN && avgsilence <= BUSY_MAX))
 #else
-	if ((hittone >= dsp->busycount - 1) && (avgtone >= BUSY_MIN && avgtone <= BUSY_MAX)) {
+	if ((hittone >= dsp->busycount - 1) && (avgtone >= BUSY_MIN && avgtone <= BUSY_MAX))
 #endif
+	{
 #ifdef BUSYDETECT_COMPARE_TONE_AND_SILENCE
 		if (avgtone > avgsilence) {
 			if (avgtone - avgtone*BUSY_PERCENT/100 <= avgsilence) {
@@ -2392,30 +2394,33 @@
 }
 #endif
 
-#ifdef TEST_FRAMEWORK
-static void test_dsp_shutdown(void)
+static int unload_module(void)
 {
 	AST_TEST_UNREGISTER(test_dsp_fax_detect);
 	AST_TEST_UNREGISTER(test_dsp_dtmf_detect);
-}
-#endif
 
-int ast_dsp_init(void)
+	return 0;
+}
+
+static int load_module(void)
 {
 	int res = _dsp_init(0);
 
-#ifdef TEST_FRAMEWORK
-	if (!res) {
-		AST_TEST_REGISTER(test_dsp_fax_detect);
-		AST_TEST_REGISTER(test_dsp_dtmf_detect);
+	AST_TEST_REGISTER(test_dsp_fax_detect);
+	AST_TEST_REGISTER(test_dsp_dtmf_detect);
 
-		ast_register_cleanup(test_dsp_shutdown);
-	}
-#endif
-	return res;
+	return res ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
 }
 
-int ast_dsp_reload(void)
+static int reload_module(void)
 {
 	return _dsp_init(1);
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "DSP",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.load_pri = AST_MODPRI_CORE,
+);
diff --git a/main/enum.c b/main/enum.c
index 5c217c4..a44a60c 100644
--- a/main/enum.c
+++ b/main/enum.c
@@ -70,6 +70,7 @@
 #include <ctype.h>
 #include <regex.h>
 
+#include "asterisk/module.h"
 #include "asterisk/enum.h"
 #include "asterisk/dns.h"
 #include "asterisk/channel.h"
@@ -1008,12 +1009,25 @@
 	return 0;
 }
 
-int ast_enum_init(void)
+static int load_module(void)
 {
-	return private_enum_init(0);
+	return private_enum_init(0) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
 }
 
-int ast_enum_reload(void)
+static int unload_module(void)
+{
+	return 0;
+}
+
+static int reload_module(void)
 {
 	return private_enum_init(1);
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "ENUM Support",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.load_pri = AST_MODPRI_CORE,
+);
diff --git a/main/features.c b/main/features.c
index 516c64a..3db6d39 100644
--- a/main/features.c
+++ b/main/features.c
@@ -40,6 +40,7 @@
 #include "asterisk.h"
 
 #include "asterisk/_private.h"
+#include "features_config.h"
 
 #include <pthread.h>
 #include <signal.h>
@@ -1145,36 +1146,32 @@
 	return 0;
 }
 
-/*!
- * \internal
- * \brief Clean up resources on Asterisk shutdown
- */
-static void features_shutdown(void)
+static int unload_module(void)
 {
-	ast_features_config_shutdown();
+	unload_features_config();
 
 	ast_manager_unregister("Bridge");
 
 	ast_unregister_application(app_bridge);
 
+	return 0;
 }
 
-int ast_features_init(void)
+static int load_module(void)
 {
 	int res;
 
-	res = ast_features_config_init();
-	if (res) {
-		return res;
-	}
+	res = load_features_config();
 	res |= ast_register_application2(app_bridge, bridge_exec, NULL, NULL, NULL);
 	res |= ast_manager_register_xml_core("Bridge", EVENT_FLAG_CALL, action_bridge);
 
-	if (res) {
-		features_shutdown();
-	} else {
-		ast_register_cleanup(features_shutdown);
-	}
-
-	return res;
+	return res ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Call Features",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_features_config,
+	.load_pri = AST_MODPRI_CORE,
+);
diff --git a/main/features_config.c b/main/features_config.c
index a773f49..f116e89 100644
--- a/main/features_config.c
+++ b/main/features_config.c
@@ -26,6 +26,8 @@
 #include "asterisk/app.h"
 #include "asterisk/cli.h"
 
+#include "features_config.h"
+
 /*** DOCUMENTATION
 	<configInfo name="features" language="en_US">
 		<synopsis>Features Configuration</synopsis>
@@ -1971,7 +1973,7 @@
 	AST_CLI_DEFINE(handle_feature_show, "Lists configured features"),
 };
 
-void ast_features_config_shutdown(void)
+void unload_features_config(void)
 {
 	ast_custom_function_unregister(&featuremap_function);
 	ast_custom_function_unregister(&feature_function);
@@ -1980,7 +1982,7 @@
 	ao2_global_obj_release(globals);
 }
 
-int ast_features_config_reload(void)
+int reload_features_config(void)
 {
 	/* Rearm the parking config options have moved warning. */
 	parking_warning = 0;
@@ -1991,7 +1993,7 @@
 	return 0;
 }
 
-int ast_features_config_init(void)
+int load_features_config(void)
 {
 	int res;
 
@@ -1999,10 +2001,6 @@
 	res |= __ast_custom_function_register(&feature_function, NULL);
 	res |= __ast_custom_function_register(&featuremap_function, NULL);
 	res |= ast_cli_register_multiple(cli_features_config, ARRAY_LEN(cli_features_config));
-
-	if (res) {
-		ast_features_config_shutdown();
-	}
 
 	return res;
 }
diff --git a/main/features_config.h b/main/features_config.h
new file mode 100644
index 0000000..8e9e4ac
--- /dev/null
+++ b/main/features_config.h
@@ -0,0 +1,28 @@
+/*
+* Asterisk -- An open source telephony toolkit.
+*
+* Copyright (C) 2018, CFWare, LLC.
+*
+* Corey Farrell <git at cfware.com>
+*
+* See http://www.asterisk.org for more information about
+* the Asterisk project. Please do not directly contact
+* any of the maintainers of this project for assistance;
+* the project provides a web site, mailing lists and IRC
+* channels for your use.
+*
+* This program is free software, distributed under the terms of
+* the GNU General Public License Version 2. See the LICENSE file
+* at the top of the source tree.
+*/
+
+#ifndef FEATURES_CONFIG_H_
+#define FEATURES_CONFIG_H_
+
+int load_features_config(void);
+
+int reload_features_config(void);
+
+void unload_features_config(void);
+
+#endif /* FEATURES_CONFIG_H_ */
diff --git a/main/http.c b/main/http.c
index 30b2fe2..55d1029 100644
--- a/main/http.c
+++ b/main/http.c
@@ -60,7 +60,7 @@
 #include "asterisk/stringfields.h"
 #include "asterisk/ast_version.h"
 #include "asterisk/manager.h"
-#include "asterisk/_private.h"
+#include "asterisk/module.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/netsock2.h"
 #include "asterisk/json.h"
@@ -2264,7 +2264,7 @@
 	return CLI_SUCCESS;
 }
 
-int ast_http_reload(void)
+static int reload_module(void)
 {
 	return __ast_http_load(1);
 }
@@ -2273,7 +2273,7 @@
 	AST_CLI_DEFINE(handle_show_http, "Display HTTP server status"),
 };
 
-static void http_shutdown(void)
+static int unload_module(void)
 {
 	struct http_uri_redirect *redirect;
 	ast_cli_unregister_multiple(cli_http, ARRAY_LEN(cli_http));
@@ -2295,14 +2295,23 @@
 		ast_free(redirect);
 	}
 	AST_RWLIST_UNLOCK(&uri_redirects);
+
+	return 0;
 }
 
-int ast_http_init(void)
+static int load_module(void)
 {
 	ast_http_uri_link(&statusuri);
 	ast_http_uri_link(&staticuri);
 	ast_cli_register_multiple(cli_http, ARRAY_LEN(cli_http));
-	ast_register_cleanup(http_shutdown);
 
-	return __ast_http_load(0);
+	return __ast_http_load(0) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Built-in HTTP Server",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.load_pri = AST_MODPRI_CORE,
+);
diff --git a/main/indications.c b/main/indications.c
index bde6e01..0ea552f 100644
--- a/main/indications.c
+++ b/main/indications.c
@@ -1114,7 +1114,7 @@
  * \internal
  * \brief Clean up resources on Asterisk shutdown
  */
-static void indications_shutdown(void)
+static int unload_module(void)
 {
 	ast_cli_unregister_multiple(cli_indications, ARRAY_LEN(cli_indications));
 	if (default_tone_zone) {
@@ -1125,29 +1125,37 @@
 		ao2_ref(ast_tone_zones, -1);
 		ast_tone_zones = NULL;
 	}
+
+	return 0;
 }
 
 /*! \brief Load indications module */
-int ast_indications_init(void)
+static int load_module(void)
 {
 	if (!(ast_tone_zones = ao2_container_alloc(NUM_TONE_ZONE_BUCKETS,
 			ast_tone_zone_hash, ast_tone_zone_cmp))) {
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	if (load_indications(0)) {
-		indications_shutdown();
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	ast_cli_register_multiple(cli_indications, ARRAY_LEN(cli_indications));
 
-	ast_register_cleanup(indications_shutdown);
-	return 0;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 /*! \brief Reload indications module */
-int ast_indications_reload(void)
+static int reload_module(void)
 {
 	return load_indications(1);
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Indication Tone Handling",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.load_pri = AST_MODPRI_CORE,
+);
diff --git a/main/loader.c b/main/loader.c
index 08d9552..4ca01fc 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -42,19 +42,12 @@
 #include "asterisk/config.h"
 #include "asterisk/channel.h"
 #include "asterisk/term.h"
-#include "asterisk/acl.h"
 #include "asterisk/manager.h"
-#include "asterisk/cdr.h"
-#include "asterisk/enum.h"
-#include "asterisk/http.h"
+#include "asterisk/io.h"
 #include "asterisk/lock.h"
-#include "asterisk/features_config.h"
-#include "asterisk/dsp.h"
-#include "asterisk/udptl.h"
 #include "asterisk/vector.h"
 #include "asterisk/app.h"
 #include "asterisk/test.h"
-#include "asterisk/sounds_index.h"
 #include "asterisk/cli.h"
 
 #include <dlfcn.h>
@@ -690,33 +683,6 @@
 	ast_update_use_count();
 }
 
-/*! \note
- * In addition to modules, the reload command handles some extra keywords
- * which are listed here together with the corresponding handlers.
- * This table is also used by the command completion code.
- */
-static struct reload_classes {
-	const char *name;
-	int (*reload_fn)(void);
-} reload_classes[] = {	/* list in alpha order, longest match first for cli completion */
-	{ "acl",         ast_named_acl_reload },
-	{ "cdr",         ast_cdr_engine_reload },
-	{ "cel",         ast_cel_engine_reload },
-	{ "dnsmgr",      dnsmgr_reload },
-	{ "dsp",         ast_dsp_reload},
-	{ "extconfig",   read_config_maps },
-	{ "enum",        ast_enum_reload },
-	{ "features",    ast_features_config_reload },
-	{ "http",        ast_http_reload },
-	{ "indications", ast_indications_reload },
-	{ "logger",      logger_reload },
-	{ "manager",     reload_manager },
-	{ "plc",         ast_plc_reload },
-	{ "sounds",      ast_sounds_reindex },
-	{ "udptl",       ast_udptl_reload },
-	{ NULL,          NULL }
-};
-
 static int printdigest(const unsigned char *d)
 {
 	int x, pos;
@@ -1160,16 +1126,6 @@
 		return NULL;
 	}
 
-	if (type == AST_MODULE_HELPER_RELOAD) {
-		int idx;
-
-		for (idx = 0; reload_classes[idx].name; idx++) {
-			if (!strncasecmp(word, reload_classes[idx].name, wordlen) && ++which > state) {
-				return ast_strdup(reload_classes[idx].name);
-			}
-		}
-	}
-
 	AST_DLLIST_LOCK(&module_list);
 	AST_DLLIST_TRAVERSE(&module_list, mod, entry) {
 		if (!module_matches_helper_type(mod, type)) {
@@ -1345,7 +1301,6 @@
 {
 	struct ast_module *cur;
 	enum ast_module_reload_result res = AST_MODULE_RELOAD_NOT_FOUND;
-	int i;
 	size_t name_baselen = name ? resource_name_baselen(name) : 0;
 
 	/* If we aren't fully booted, we just pretend we reloaded but we queue this
@@ -1378,22 +1333,6 @@
 			res = AST_MODULE_RELOAD_ERROR;
 			goto module_reload_done;
 		}
-	}
-
-	/* Call "predefined" reload here first */
-	for (i = 0; reload_classes[i].name; i++) {
-		if (!name || !strcasecmp(name, reload_classes[i].name)) {
-			if (reload_classes[i].reload_fn() == AST_MODULE_LOAD_SUCCESS) {
-				res = AST_MODULE_RELOAD_SUCCESS;
-			}
-		}
-	}
-
-	if (name && res == AST_MODULE_RELOAD_SUCCESS) {
-		if (ast_opt_lock_confdir) {
-			ast_unlock_path(ast_config_AST_CONFIG_DIR);
-		}
-		goto module_reload_done;
 	}
 
 	AST_DLLIST_LOCK(&module_list);
@@ -1516,6 +1455,10 @@
 		}
 
 		mod->flags.running = 1;
+		if (mod->flags.builtin) {
+			/* Built-in modules cannot be unloaded. */
+			ast_module_shutdown_ref(mod);
+		}
 
 		ast_update_use_count();
 		break;
@@ -1881,6 +1824,19 @@
 		ast_module_register(resource_being_loaded->info);
 	}
 
+	if (!preload_only) {
+		struct ast_module *mod;
+
+		/* Add all built-in modules to the load order. */
+		AST_DLLIST_TRAVERSE(&module_list, mod, entry) {
+			if (!mod->flags.builtin) {
+				continue;
+			}
+
+			add_to_load_order(mod->resource, &load_order, 0);
+		}
+	}
+
 	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);
diff --git a/main/logger.c b/main/logger.c
index 6060b3c..46d61ed 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -49,6 +49,7 @@
 #include <fcntl.h>
 
 #include "asterisk/_private.h"
+#include "asterisk/module.h"
 #include "asterisk/paths.h"	/* use ast_config_AST_LOG_DIR */
 #include "asterisk/logger.h"
 #include "asterisk/lock.h"
@@ -1123,16 +1124,6 @@
 	}
 
 	return res;
-}
-
-/*! \brief Reload the logger module without rotating log files (also used from loader.c during
-	a full Asterisk reload) */
-int logger_reload(void)
-{
-	if (reload_logger(0, NULL)) {
-		return RESULT_FAILURE;
-	}
-	return RESULT_SUCCESS;
 }
 
 static char *handle_logger_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -2369,3 +2360,27 @@
 {
 	return logger_queue_limit;
 }
+
+static int reload_module(void)
+{
+	return reload_logger(0, NULL);
+}
+
+static int unload_module(void)
+{
+	return 0;
+}
+
+static int load_module(void)
+{
+	return AST_MODULE_LOAD_SUCCESS;
+}
+
+/* Logger is initialized separate from the module loader, only reload_module does anything. */
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Logger",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.load_pri = 0,
+);
diff --git a/main/manager.c b/main/manager.c
index b698702..64b07d3 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -2710,6 +2710,8 @@
 	return CLI_SUCCESS;
 }
 
+static int reload_module(void);
+
 /*! \brief CLI command manager reload */
 static char *handle_manager_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
@@ -2726,7 +2728,7 @@
 	if (a->argc > 2) {
 		return CLI_SHOWUSAGE;
 	}
-	reload_manager();
+	reload_module();
 	return CLI_SUCCESS;
 }
 
@@ -8971,8 +8973,6 @@
 #endif
 		int res;
 
-		ast_register_cleanup(manager_shutdown);
-
 		res = STASIS_MESSAGE_TYPE_INIT(ast_manager_get_generic_type);
 		if (res != 0) {
 			return -1;
@@ -9455,12 +9455,19 @@
 	__init_manager(1, 1);
 }
 
-int init_manager(void)
+static int unload_module(void)
 {
-	return __init_manager(0, 0);
+	return 0;
 }
 
-int reload_manager(void)
+static int load_module(void)
+{
+	ast_register_cleanup(manager_shutdown);
+
+	return __init_manager(0, 0) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
+}
+
+static int reload_module(void)
 {
 	return __init_manager(1, 0);
 }
@@ -9557,3 +9564,12 @@
 
 	return ev;
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Asterisk Manager Interface",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.load_pri = AST_MODPRI_CORE,
+	.requires = "http",
+);
diff --git a/main/named_acl.c b/main/named_acl.c
index 3a4c454..4f2069a 100644
--- a/main/named_acl.c
+++ b/main/named_acl.c
@@ -27,6 +27,11 @@
  * Olle E. Johansson <oej at edvina.net>
  */
 
+/* This maintains the original "module reload acl" CLI command instead
+ * of replacing it with "module reload named_acl". */
+#undef AST_MODULE
+#define AST_MODULE "acl"
+
 #include "asterisk.h"
 
 #include "asterisk/config.h"
@@ -397,36 +402,6 @@
 
 /*!
  * \internal
- * \brief reload configuration for named ACLs
- *
- * \param fd file descriptor for CLI client
- */
-int ast_named_acl_reload(void)
-{
-	enum aco_process_status status;
-
-	status = aco_process_config(&cfg_info, 1);
-
-	if (status == ACO_PROCESS_ERROR) {
-		ast_log(LOG_WARNING, "Could not reload ACL config\n");
-		return 0;
-	}
-
-	if (status == ACO_PROCESS_UNCHANGED) {
-		/* We don't actually log anything if the config was unchanged,
-		 * but we don't need to send a config change event either.
-		 */
-		return 0;
-	}
-
-	/* We need to push an ACL change event with no ACL name so that all subscribers update with all ACLs */
-	publish_acl_change("");
-
-	return 0;
-}
-
-/*!
- * \internal
  * \brief secondary handler for the 'acl show <name>' command (with arg)
  *
  * \param fd file descriptor of the cli
@@ -552,26 +527,48 @@
 	AST_CLI_DEFINE(handle_show_named_acl_cmd, "Show a named ACL or list all named ACLs"),
 };
 
-static void named_acl_cleanup(void)
+static int reload_module(void)
+{
+	enum aco_process_status status;
+
+	status = aco_process_config(&cfg_info, 1);
+
+	if (status == ACO_PROCESS_ERROR) {
+		ast_log(LOG_WARNING, "Could not reload ACL config\n");
+		return 0;
+	}
+
+	if (status == ACO_PROCESS_UNCHANGED) {
+		/* We don't actually log anything if the config was unchanged,
+		 * but we don't need to send a config change event either.
+		 */
+		return 0;
+	}
+
+	/* We need to push an ACL change event with no ACL name so that all subscribers update with all ACLs */
+	publish_acl_change("");
+
+	return 0;
+}
+
+static int unload_module(void)
 {
 	ast_cli_unregister_multiple(cli_named_acl, ARRAY_LEN(cli_named_acl));
 
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_named_acl_change_type);
 	aco_info_destroy(&cfg_info);
 	ao2_global_obj_release(globals);
+
+	return 0;
 }
 
-int ast_named_acl_init()
+static int load_module(void)
 {
-	ast_cli_register_multiple(cli_named_acl, ARRAY_LEN(cli_named_acl));
+	if (aco_info_init(&cfg_info)) {
+		return AST_MODULE_LOAD_FAILURE;
+	}
 
 	STASIS_MESSAGE_TYPE_INIT(ast_named_acl_change_type);
-
-	ast_register_cleanup(named_acl_cleanup);
-
-	if (aco_info_init(&cfg_info)) {
-		return 0;
-	}
 
 	/* Register the per level options. */
 	aco_option_register(&cfg_info, "permit", ACO_EXACT, named_acl_types, NULL, OPT_ACL_T, 1, FLDSET(struct named_acl, ha));
@@ -579,5 +576,15 @@
 
 	aco_process_config(&cfg_info, 0);
 
-	return 0;
+	ast_cli_register_multiple(cli_named_acl, ARRAY_LEN(cli_named_acl));
+
+	return AST_MODULE_LOAD_SUCCESS;
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Named ACL system",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.load_pri = AST_MODPRI_CORE,
+);
diff --git a/main/plc.c b/main/plc.c
index 2a8279f..847ce65 100644
--- a/main/plc.c
+++ b/main/plc.c
@@ -38,6 +38,8 @@
 
 #include <math.h>
 
+#include "asterisk/config.h"
+#include "asterisk/module.h"
 #include "asterisk/plc.h"
 
 #if !defined(FALSE)
@@ -246,3 +248,43 @@
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
+
+static int reload_module(void)
+{
+	struct ast_variable *var;
+	struct ast_flags config_flags = { 0 };
+	struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
+
+	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
+		return 0;
+	}
+
+	for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
+		if (!strcasecmp(var->name, "genericplc")) {
+			ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC);
+		}
+	}
+	ast_config_destroy(cfg);
+
+	return 0;
+}
+
+static int load_module(void)
+{
+	reload_module();
+
+	return AST_MODULE_LOAD_SUCCESS;
+}
+
+static int unload_module(void)
+{
+	return 0;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "PLC",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.load_pri = AST_MODPRI_CORE,
+);
diff --git a/main/sounds.c b/main/sounds.c
index c792c1b..08e2927 100644
--- a/main/sounds.c
+++ b/main/sounds.c
@@ -34,7 +34,7 @@
 #include "asterisk/sounds_index.h"
 #include "asterisk/file.h"
 #include "asterisk/cli.h"
-#include "asterisk/_private.h"
+#include "asterisk/module.h"
 #include "asterisk/stasis_message_router.h"
 #include "asterisk/stasis_system.h"
 
@@ -111,7 +111,7 @@
 
 AST_MUTEX_DEFINE_STATIC(reload_lock);
 
-int ast_sounds_reindex(void)
+static int reload_module(void)
 {
 	RAII_VAR(struct ast_str *, sounds_dir, NULL, ast_free);
 	RAII_VAR(struct ao2_container *, languages, NULL, ao2_cleanup);
@@ -273,13 +273,15 @@
 	AST_CLI_DEFINE(handle_cli_sound_show, "Shows details about a specific sound"),
 };
 
-static void sounds_cleanup(void)
+static int unload_module(void)
 {
 	stasis_message_router_unsubscribe_and_join(sounds_system_router);
 	sounds_system_router = NULL;
 	ast_cli_unregister_multiple(cli_sounds, ARRAY_LEN(cli_sounds));
 	ao2_cleanup(sounds_index);
 	sounds_index = NULL;
+
+	return 0;
 }
 
 static void format_update_cb(void *data, struct stasis_subscription *sub,
@@ -287,21 +289,21 @@
 {
 	/* Reindexing during shutdown is pointless. */
 	if (!ast_shutting_down()) {
-		ast_sounds_reindex();
+		reload_module();
 	}
 }
 
-int ast_sounds_index_init(void)
+static int load_module(void)
 {
 	int res = 0;
-	if (ast_sounds_reindex()) {
-		return -1;
+	if (reload_module()) {
+		return AST_MODULE_LOAD_FAILURE;
 	}
 	res |= ast_cli_register_multiple(cli_sounds, ARRAY_LEN(cli_sounds));
 
 	sounds_system_router = stasis_message_router_create(ast_system_topic());
 	if (!sounds_system_router) {
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	if (ast_format_register_type()) {
@@ -320,15 +322,19 @@
 			NULL);
 	}
 
-	if (res) {
-		return -1;
-	}
-
-	ast_register_cleanup(sounds_cleanup);
-	return 0;
+	return res ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
 }
 
 struct ast_media_index *ast_sounds_get_index(void)
 {
 	return ao2_bump(sounds_index);
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Sounds Index",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	/* Load after the format modules to reduce processing during startup. */
+	.load_pri = AST_MODPRI_APP_DEPEND + 1,
+);
diff --git a/main/udptl.c b/main/udptl.c
index 5a491e6..f6cd3b9 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -67,6 +67,7 @@
 #include <signal.h>
 #include <fcntl.h>
 
+#include "asterisk/module.h"
 #include "asterisk/udptl.h"
 #include "asterisk/frame.h"
 #include "asterisk/channel.h"
@@ -1355,9 +1356,10 @@
 	return 0;
 }
 
-int ast_udptl_reload(void)
+static int reload_module(void)
 {
 	__ast_udptl_reload(1);
+
 	return 0;
 }
 
@@ -1365,17 +1367,19 @@
  * \internal
  * \brief Clean up resources on Asterisk shutdown
  */
-static void udptl_shutdown(void)
+static int unload_module(void)
 {
 	ast_cli_unregister_multiple(cli_udptl, ARRAY_LEN(cli_udptl));
 	ao2_t_global_obj_release(globals, "Unref udptl global container in shutdown");
 	aco_info_destroy(&cfg_info);
+
+	return 0;
 }
 
-void ast_udptl_init(void)
+static int load_module(void)
 {
 	if (aco_info_init(&cfg_info)) {
-		return;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	aco_option_register(&cfg_info, "udptlstart", ACO_EXACT, general_options, __stringify(DEFAULT_UDPTLSTART),
@@ -1407,5 +1411,13 @@
 
 	ast_cli_register_multiple(cli_udptl, ARRAY_LEN(cli_udptl));
 
-	ast_register_cleanup(udptl_shutdown);
+	return AST_MODULE_LOAD_SUCCESS;
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "UDPTL",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.load_pri = AST_MODPRI_CORE,
+);
diff --git a/res/res_ari.c b/res/res_ari.c
index 5ffb583..354201b 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -1196,6 +1196,6 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.optional_modules = "res_http_websocket",
-	.requires = "res_stasis",
+	.requires = "http,res_stasis",
 	.load_pri = AST_MODPRI_APP_DEPEND,
 );
diff --git a/res/res_config_curl.c b/res/res_config_curl.c
index 03f0338..03ff80c 100644
--- a/res/res_config_curl.c
+++ b/res/res_config_curl.c
@@ -650,5 +650,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_REALTIME_DRIVER,
-	.requires = "res_curl,func_curl",
+	.requires = "extconfig,res_curl,func_curl",
 );
diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c
index 10265c9..9250a47 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -1999,4 +1999,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_REALTIME_DRIVER,
+	.requires = "extconfig",
 );
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index 186e89d..658e465 100644
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -1237,4 +1237,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_REALTIME_DRIVER,
+	.requires = "extconfig,res_odbc",
 );
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index cee4e48..119e196 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -1720,4 +1720,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_REALTIME_DRIVER,
+	.requires = "extconfig",
 );
diff --git a/res/res_config_sqlite.c b/res/res_config_sqlite.c
index 83d2dca..b57668b 100644
--- a/res/res_config_sqlite.c
+++ b/res/res_config_sqlite.c
@@ -1777,4 +1777,5 @@
 	.load = load_module,
 	.unload = unload_module,
 	.load_pri = AST_MODPRI_REALTIME_DRIVER,
+	.requires = "cdr",
 );
diff --git a/res/res_config_sqlite3.c b/res/res_config_sqlite3.c
index de2de1c..854034f 100644
--- a/res/res_config_sqlite3.c
+++ b/res/res_config_sqlite3.c
@@ -1393,4 +1393,5 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_REALTIME_DRIVER,
+	.requires = "extconfig",
 );
diff --git a/res/res_http_post.c b/res/res_http_post.c
index 44bb8ee..9313310 100644
--- a/res/res_http_post.c
+++ b/res/res_http_post.c
@@ -513,4 +513,5 @@
 	.load = load_module,
 	.unload = unload_module,
 	.reload = reload,
+	.requires = "http",
 );
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index 223bb2d..9a32bf3 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -1478,4 +1478,5 @@
 	.load = load_module,
 	.unload = unload_module,
 	.load_pri = AST_MODPRI_CHANNEL_DEPEND,
+	.requires = "http",
 );
diff --git a/res/res_phoneprov.c b/res/res_phoneprov.c
index 585056b..70e1333 100644
--- a/res/res_phoneprov.c
+++ b/res/res_phoneprov.c
@@ -1498,6 +1498,7 @@
 	.unload = unload_module,
 	.reload = reload,
 	.load_pri = AST_MODPRI_CHANNEL_DEPEND,
+	.requires = "http",
 );
 
 /****  Public API for register/unregister, set defaults, and add extension. ****/
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index ca173a8..418a679 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -5213,6 +5213,6 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CHANNEL_DEPEND - 5,
-	.requires = "res_pjproject",
+	.requires = "dnsmgr,res_pjproject",
 	.optional_modules = "res_statsd",
 );
diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c
index 249472b..333295f 100644
--- a/res/res_pjsip_t38.c
+++ b/res/res_pjsip_t38.c
@@ -1048,5 +1048,5 @@
 	.load = load_module,
 	.unload = unload_module,
 	.load_pri = AST_MODPRI_CHANNEL_DRIVER,
-	.requires = "res_pjsip,res_pjsip_session",
+	.requires = "res_pjsip,res_pjsip_session,udptl",
 );

-- 
To view, visit https://gerrit.asterisk.org/8390
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I371a9a45064f20026c492623ea8062d02a1ab97f
Gerrit-Change-Number: 8390
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180224/49ac9462/attachment-0001.html>


More information about the asterisk-code-review mailing list