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

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I371a9a45064f20026c492623ea8062d02a1ab97f </div>
<div style="display:none"> Gerrit-Change-Number: 8390 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>