]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
loader: Convert reload_classes to built-in modules.
authorCorey Farrell <git@cfware.com>
Sat, 17 Feb 2018 03:11:42 +0000 (22:11 -0500)
committerCorey Farrell <git@cfware.com>
Wed, 14 Mar 2018 09:20:12 +0000 (05:20 -0400)
* acl (named_acl.c)
* cdr
* cel
* ccss
* dnsmgr
* dsp
* enum
* extconfig (config.c)
* features
* http
* indications
* logger
* manager
* plc
* sounds
* udptl

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

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

Change-Id: I371a9a45064f20026c492623ea8062d02a1ab97f

79 files changed:
addons/cdr_mysql.c
addons/chan_ooh323.c
addons/res_config_mysql.c
apps/app_celgenuserevent.c
apps/app_dial.c
apps/app_forkcdr.c
cdr/cdr_adaptive_odbc.c
cdr/cdr_beanstalkd.c
cdr/cdr_csv.c
cdr/cdr_custom.c
cdr/cdr_manager.c
cdr/cdr_odbc.c
cdr/cdr_pgsql.c
cdr/cdr_radius.c
cdr/cdr_sqlite.c
cdr/cdr_sqlite3_custom.c
cdr/cdr_syslog.c
cdr/cdr_tds.c
cel/cel_beanstalkd.c
cel/cel_custom.c
cel/cel_manager.c
cel/cel_odbc.c
cel/cel_pgsql.c
cel/cel_radius.c
cel/cel_sqlite3_custom.c
cel/cel_tds.c
channels/chan_dahdi.c
channels/chan_iax2.c
channels/chan_sip.c
funcs/func_callcompletion.c
funcs/func_cdr.c
funcs/func_enum.c
include/asterisk/_private.h
include/asterisk/acl.h
include/asterisk/ccss.h
include/asterisk/cdr.h
include/asterisk/config.h
include/asterisk/dsp.h
include/asterisk/enum.h
include/asterisk/features_config.h
include/asterisk/logger.h
include/asterisk/manager.h
include/asterisk/module.h
include/asterisk/sounds_index.h
include/asterisk/udptl.h
main/Makefile
main/asterisk.c
main/ccss.c
main/cdr.c
main/cel.c
main/channel.c
main/config.c
main/dnsmgr.c
main/dsp.c
main/enum.c
main/features.c
main/features_config.c
main/features_config.h [new file with mode: 0644]
main/http.c
main/indications.c
main/loader.c
main/logger.c
main/manager.c
main/named_acl.c
main/plc.c
main/sounds.c
main/udptl.c
res/res_ari.c
res/res_config_curl.c
res/res_config_ldap.c
res/res_config_odbc.c
res/res_config_pgsql.c
res/res_config_sqlite.c
res/res_config_sqlite3.c
res/res_http_post.c
res/res_http_websocket.c
res/res_phoneprov.c
res/res_pjsip.c
res/res_pjsip_t38.c

index 00c75dd684bbef908fb3fcc3ae31d630e3ff7f3c..2fefe4ed1713c020de27e2d79787adc5f1f2c721 100644 (file)
@@ -724,4 +724,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "MySQL CDR Backend",
        .load = load_module,
        .unload = unload_module,
        .reload = reload,
+       .requires = "cdr",
 );
index 278c5876f6a0abddda3d6fd4bccb5d22e95eddc4..ffdbf67211f8168bf39860bb5b99b6ebd6cd5b56 100644 (file)
@@ -5243,5 +5243,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Objective Systems H32
        .load = load_module,
        .unload = unload_module,
        .reload = reload_module,
-       .load_pri = AST_MODPRI_CHANNEL_DRIVER
+       .load_pri = AST_MODPRI_CHANNEL_DRIVER,
+       .requires = "udptl",
 );
index ae4348500eb19551d7a5fc616056c7cd125afd98..edd9385061cab83788b5f6923ccae42489f6630d 100644 (file)
@@ -1559,4 +1559,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "MySQL RealTime Config
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_REALTIME_DRIVER,
+       .requires = "extconfig",
 );
index 67c7fbcbd752f5eaf41d00666039d62d834218f4..11b11b07c829ccece6c9b9e1500156c2c8e4207b 100644 (file)
@@ -103,4 +103,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generate an User-Defined
        .support_level = AST_MODULE_SUPPORT_CORE,
        .load = load_module,
        .unload = unload_module,
+       .requires = "cel",
 );
index 257ff472aaa614110c0df13e56aa1a8b817ff062..9d6f5beafe73c3975a88ed21b8f5428f0f95d1af 100644 (file)
@@ -3378,4 +3378,9 @@ static int load_module(void)
        return res;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Dialing Application");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Dialing Application",
+       .support_level = AST_MODULE_SUPPORT_CORE,
+       .load = load_module,
+       .unload = unload_module,
+       .requires = "ccss",
+);
index 73963f3e165b80e0571808fe77615fc3a51443c4..25b56cb5afd6db9201391f8d8d96ab9500e2ade9 100644 (file)
@@ -215,4 +215,9 @@ static int load_module(void)
        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",
+);
index e04b9fec88c0a1561de2eb23e1e758c0fd364e24..feb62e9fbdf231aec4e97ecab95f24948047a919 100644 (file)
@@ -831,4 +831,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Adaptive ODBC CDR bac
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cdr,res_odbc",
 );
index 8f4863aa52800ef84057847e5a0b6aab95cc4b55..524274ffb765442bea0511483d5d822c93f52d72 100644 (file)
@@ -261,9 +261,10 @@ static int reload(void) {
 }
 
 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",
 );
index 5666a3d4eea68ffa4a20bc44d91687f5a4a6ae17..e4c74ff1efbb4d3b0f4b54937d9397adf71b8002 100644 (file)
@@ -360,4 +360,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Comma Separated Value
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cdr",
 );
index 5a5eb9ed07e6dde6f52ce0cc019f62d729723b13..72a475c8c9e88056d611d0493e25559d87c63d29 100644 (file)
@@ -231,4 +231,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Customizable Comma Se
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cdr",
 );
index 3f0cc6b6dda065f2b0afb06ec19c3ee86081a2c2..74f37d207f3c56396a4158e90c8ad3f661b73914 100644 (file)
@@ -371,4 +371,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Asterisk Manager Inte
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cdr",
 );
index efa68c1a922bbb6bc02aec86a5e9b3cbb53c7199..54ca1b9e381efb17e69799da3b3c4ca02f33519a 100644 (file)
@@ -328,4 +328,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ODBC CDR Backend",
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cdr",
 );
index 3af9b4b3b2b6cb399dcfe7bea580013e67d8270a..a4919d57f76e2e02b13ae8911ccf32299f877c4a 100644 (file)
@@ -794,4 +794,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PostgreSQL CDR Backen
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cdr",
 );
index a43e96cd8392686fda6f8229e48f16b484a7bc22..0a5fa6371c98358a1b6f598d7442a4f8178949e1 100644 (file)
@@ -287,4 +287,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "RADIUS CDR Backend",
        .load = load_module,
        .unload = unload_module,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cdr",
 );
index b91296073b3501a28a84bb411d916a4d06e67a09..aceff0f57a928e5aa9be10e7b02174da93911bb4 100644 (file)
@@ -248,4 +248,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SQLite CDR Backend",
        .load = load_module,
        .unload = unload_module,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cdr",
 );
index 2212d04992e724f5487339de2262b452e21d2f81..9f71c8481cc9b1032e7ea84174473bf3de59ee42 100644 (file)
@@ -360,4 +360,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SQLite3 Custom CDR Mo
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cdr",
 );
index bbc44064f37c23dc7e97c7b9b8fe0c41a888c6be..4f0a78ccb286ad7f506fe95e74e286ff55562e72 100644 (file)
@@ -292,4 +292,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Customizable syslog C
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cdr",
 );
index f3d0628ec62e74f4cd9b91f59917acd1b7dee18c..2de4e426ae7199b5f74c23caa0b65c7be4507985 100644 (file)
@@ -635,4 +635,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "FreeTDS CDR Backend",
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cdr",
 );
index e6f23808c3f43c96b50787f1826c46a92adde4f9..fe4f430e97214e88354a7a003257b2d00831cc58 100644 (file)
@@ -272,4 +272,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Beanstalkd CEL Backen
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cel",
 );
index 9c81ee1d4001adbcbc3418584858a90b51020e58..73423a362bbf3822ab6612b33212dd12ad95df52 100644 (file)
@@ -223,4 +223,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Customizable Comma Se
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cel",
 );
index 365bb70c2849bae3155fb0c3d968147745c6defc..e485aab4961d9a4d4708b1d9c6803031dec8a921 100644 (file)
@@ -380,4 +380,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Asterisk Manager Inte
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cel",
 );
index b4967b647ecfa38da417460e2870196de20c801f..04d37346d11fa995f701482143bd13fc40a510cb 100644 (file)
@@ -856,4 +856,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ODBC CEL backend",
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cel,res_odbc",
 );
index eb8f5d83652fa85ab3afa5255e591ea670b0c49e..77dd46ae721507288d70b5fcda21e1d68e022424 100644 (file)
@@ -709,4 +709,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PostgreSQL CEL Backen
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cel",
 );
index 250d6a77813c2d5348421aad61e288efedb701f3..4e87f86d5d3000ccd259fd97aecb6d4d4f728d43 100644 (file)
@@ -259,4 +259,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "RADIUS CEL Backend",
        .load = load_module,
        .unload = unload_module,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cel",
 );
index 5675da6b33f5cb43a71f4ec13128b42b3d29e51e..db38eaf3eb01cd6b9b647dea3f4f040d8069f842 100644 (file)
@@ -360,4 +360,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SQLite3 Custom CEL Mo
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cel",
 );
index 0859fab7ac14996321fffa698aae380536d36720..0aa73e52238f9b808330cb474bc0b7912feaa673 100644 (file)
@@ -580,4 +580,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "FreeTDS CEL Backend",
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CDR_DRIVER,
+       .requires = "cel",
 );
index 0579a5a36dba9b3c1dea444ded4acc77ac5bb6da..37e277432c101b5a3c22f1fd5c738919c4e8612e 100644 (file)
@@ -19542,5 +19542,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, tdesc,
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CHANNEL_DRIVER,
+       .requires = "ccss",
        .optional_modules = "res_smdi",
 );
index eade5d13cf58229f602cf230e4bafb1bf0b9b199..dec9dfda128acdda2b911f89e996d077affdef2b 100644 (file)
@@ -14902,5 +14902,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Inter Asterisk eXchan
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CHANNEL_DRIVER,
+       .requires = "dnsmgr",
        .optional_modules = "res_crypto",
 );
index cd29294487a414708ce6beeb117f8e2eeb790be6..5030af453fe32f00adcc504a6007580daf48759f 100644 (file)
@@ -35744,5 +35744,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Session Initiation Pr
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CHANNEL_DRIVER,
+       .requires = "ccss,dnsmgr,udptl",
        .optional_modules = "res_crypto,res_http_websocket",
 );
index ed5238c1f0462458e58a9b888c6414e7a1dc6a00..37ba38ce40ea2c5b5b60ceb4131b7c3972ff43f5 100644 (file)
@@ -126,4 +126,9 @@ static int load_module(void)
        return ast_custom_function_register(&cc_function) == 0 ? AST_MODULE_LOAD_SUCCESS : AST_MODULE_LOAD_DECLINE;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call Control Configuration Function");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Call Control Configuration Function",
+       .support_level = AST_MODULE_SUPPORT_CORE,
+       .load = load_module,
+       .unload = unload_module,
+       .requires = "ccss",
+);
index 2dd9f157857820f9d508d156dcf460d8a34bbb62..d7bc211452db9c207e18965e025edcfdf8c1496d 100644 (file)
@@ -704,4 +704,9 @@ static int load_module(void)
        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",
+);
index 6929e3ccd7536c0cb5417ebcb7a7949cafed5864..f649e0f29752fc87b90678603c4ca733c9e7bf94 100644 (file)
@@ -472,4 +472,9 @@ static int load_module(void)
        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",
+);
index b9f552dd1be293f64279c0dcb5db82c4e743ce73..431f961083ad7669cfa3f9b13d45bf33064c5295 100644 (file)
@@ -33,26 +33,17 @@ int astdb_init(void);                       /*!< Provided by db.c */
 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 */
@@ -97,13 +88,6 @@ void ast_process_pending_reloads(void);
  */
 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);
 
@@ -113,9 +97,6 @@ int ast_rtp_engine_init(void);
  */
 int ast_parking_stasis_init(void);
 
-/*! \brief initialize the sounds index */
-int ast_sounds_index_init(void);
-
 /*!
  * \brief Endpoint support initialization.
  * \return 0 on success.
index bda1c7606de5480485fb77cd5dcd3bd056fe8435..09adc527df490348b1844bd62e5d70fcb14b0f9a 100644 (file)
@@ -381,24 +381,6 @@ const char *ast_tos2str(unsigned int tos);
  */
 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
index fb17500b636e09e75ab7e1b81bd086b1c231dba8..c006c7639e8af3e68497c550c4f21f80a262cf6e 100644 (file)
@@ -1618,15 +1618,4 @@ typedef void (*ast_cc_callback_fn)(struct ast_channel *chan, struct ast_cc_confi
  */
 int ast_cc_callback(struct ast_channel *inbound, const char * const tech, const char * const dest, ast_cc_callback_fn callback);
 
-/*!
- * \since 1.8
- * \brief Initialize CCSS
- *
- * Performs startup routines necessary for CC operation.
- *
- * \retval 0 Success
- * \retval nonzero Failure
- */
-int ast_cc_init(void);
-
 #endif /* _ASTERISK_CCSS_H */
index e10da822327e33374c4ecb87f20f839e15c310ee..c6b241315c836e1011c002641e4b12da4ce48683 100644 (file)
@@ -581,12 +581,6 @@ const char *ast_cdr_disp2str(int disposition);
  */
 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);
 
index fd9641e9924f8b27b38c83771d1a932fc243a53e..a7b144e275cf0c4cf530c29e168e17b9fd23a52f 100644 (file)
@@ -784,15 +784,6 @@ int ast_realtime_append_mapping(const char *name, const char *driver, const char
  */
 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);
 
index d092e6b4c35f849660a23104ab6c08dbbcb34ee0..769d3b9814c8b50d7d682e958f2e217a2139b5b9 100644 (file)
@@ -193,16 +193,4 @@ int ast_dsp_get_tcount(struct ast_dsp *dsp);
  */
 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 */
index 877c0c3cff8442df81c59141d4f7d920df5a74b9..2ce85ccb3a5827c1cbe3756aec0a18e812f6e0fb 100644 (file)
@@ -97,7 +97,4 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *location, i
  */
 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 */
index 1bce50bba23733dcc5803bdf384c0ce4d29c5c0e..cd1bbbceaee57cbedd80ec087b49a0d83eb71b10 100644 (file)
@@ -265,10 +265,4 @@ struct ast_applicationmap_item {
  */
 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 */
index 8b1e5fe0159d142dde260de0ac3d17ea744014b6..df039313cee8d7772939ee9e46226d2c561abda6 100644 (file)
@@ -133,9 +133,6 @@ int ast_logger_remove_channel(const char *log_channel);
  */
 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);
 
index 35dc227633e2834e26fd838bff5a4758bf181bee..97d4b9c2984521a0cc6ff8027b82b6bfe4664637 100644 (file)
@@ -356,12 +356,6 @@ void __attribute__((format(printf, 2, 3))) astman_append(struct mansession *s, c
 /*! \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
  *
index ebd41c06dd44856cfe96c576344701fc44d97a9e..faa4f7f67d22ea3062cb248e36cb7d3871ce4466 100644 (file)
@@ -292,13 +292,14 @@ enum ast_module_load_priority {
        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_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) */
-       AST_MODPRI_APP_DEPEND =         70,  /*!< Dependency for an application */
-       AST_MODPRI_DEVSTATE_PROVIDER =  80,  /*!< Applications and other modules that _provide_ devicestate (e.g. meetme) */
-       AST_MODPRI_DEVSTATE_PLUGIN =    90,  /*!< Plugin for a module that provides devstate (e.g. res_calendar_*) */
-       AST_MODPRI_CDR_DRIVER =        100,  /*!< CDR or CEL backend */
+       AST_MODPRI_CORE =               40,  /*!< A core module originally meant to start between preload and load. */
+       AST_MODPRI_TIMING =             50,  /*!< Dependency for a channel (MOH needs timing interfaces to be fully loaded) */
+       AST_MODPRI_CHANNEL_DEPEND =     60,  /*!< Channel driver dependency (may depend upon realtime, e.g. MOH) */
+       AST_MODPRI_CHANNEL_DRIVER =     70,  /*!< Channel drivers (provide devicestate) */
+       AST_MODPRI_APP_DEPEND =         80,  /*!< Dependency for an application */
+       AST_MODPRI_DEVSTATE_PROVIDER =  90,  /*!< Applications and other modules that _provide_ devicestate (e.g. meetme) */
+       AST_MODPRI_DEVSTATE_PLUGIN =   100,  /*!< Plugin for a module that provides devstate (e.g. res_calendar_*) */
+       AST_MODPRI_CDR_DRIVER =        110,  /*!< CDR or CEL backend */
        AST_MODPRI_DEFAULT =           128,  /*!< Modules not otherwise defined (such as most apps) will load here */
        AST_MODPRI_DEVSTATE_CONSUMER = 150,  /*!< Certain modules, which consume devstate, need to load after all others (e.g. app_queue) */
 };
index d7eb053321949544173c30862b2f0201d5b815e2..bbd3965f4870e90a45af2e61d1b37e0276e803ea 100644 (file)
@@ -32,14 +32,6 @@ extern "C" {
  */
 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
  *
index 7137ff93693cda7ae00b074b787c005ad37fdffe..0d79d6f663eb8801fc469cb86a7582b7d882ef75 100644 (file)
@@ -126,13 +126,6 @@ void ast_udptl_setnat(struct ast_udptl *udptl, int nat);
 
 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
index ba7491d0ecf7982bae15ac137799ea7e09e59d50..cd5c08c02549e211722a7b869cc3735f982f3b46 100644 (file)
@@ -17,9 +17,9 @@ all: asterisk
 
 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 ccss.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)
index bec992f688882d37f7a78bb97b219f8b5a81297f..2a7e3016684412bf3cc8a9aec211d30ea2174abf 100644 (file)
@@ -199,7 +199,6 @@ int daemon(int, int);  /* defined in libresolv of all places */
 #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 @@ int daemon(int, int);  /* defined in libresolv of all places */
 #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,11 +220,9 @@ int daemon(int, int);  /* defined in libresolv of all places */
 #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"
-#include "asterisk/ccss.h"
 #include "asterisk/test.h"
 #include "asterisk/rtp_engine.h"
 #include "asterisk/format.h"
@@ -4445,12 +4438,7 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou
 
        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");
@@ -4565,31 +4553,9 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou
        /* 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
         * cache can't be constructed from items in the AstDB without their
index ed0bba7f51cf25c87fd6b27cc3973da30cab9d3d..29780d8755da742df536e96941fe1a1292baaea5 100644 (file)
@@ -4616,7 +4616,7 @@ static struct ast_cli_entry cc_cli[] = {
        AST_CLI_DEFINE(handle_cc_kill, "Kill a CC transaction"),
 };
 
-static void cc_shutdown(void)
+static int unload_module(void)
 {
        ast_devstate_prov_del("ccss");
        ast_cc_agent_unregister(&generic_agent_callbacks);
@@ -4642,30 +4642,32 @@ static void cc_shutdown(void)
                ao2_t_ref(generic_monitors, -1, "Unref generic_monitor container in cc_shutdown");
                generic_monitors = NULL;
        }
+
+       return 0;
 }
 
-int ast_cc_init(void)
+static int load_module(void)
 {
        int res;
 
        if (!(cc_core_instances = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,
                                        cc_core_instance_hash_fn, cc_core_instance_cmp_fn,
                                        "Create core instance container"))) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
        if (!(generic_monitors = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,
                        generic_monitor_instance_list_hash_fn, generic_monitor_instance_list_cmp_fn,
                        "Create generic monitor container"))) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
        if (!(cc_core_taskprocessor = ast_taskprocessor_get("CCSS_core", TPS_REF_DEFAULT))) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
        if (!(cc_sched_context = ast_sched_context_create())) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
        if (ast_sched_start_thread(cc_sched_context)) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
        res = ast_register_application2(ccreq_app, ccreq_exec, NULL, NULL, NULL);
        res |= ast_register_application2(cccancel_app, cccancel_exec, NULL, NULL, NULL);
@@ -4681,7 +4683,12 @@ int ast_cc_init(void)
        initialize_cc_devstate_map();
        res |= ast_devstate_prov_add("ccss", ccss_device_state);
 
-       ast_register_cleanup(cc_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 Completion Supplementary Services",
+       .support_level = AST_MODULE_SUPPORT_CORE,
+       .load = load_module,
+       .unload = unload_module,
+       .load_pri = AST_MODPRI_CORE,
+);
index 4acadf975f97a7f711b7d1517d749a456060e74f..462e9c189cddd2b653c47d4baba6f7addc34a241 100644 (file)
@@ -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 @@ static int process_config(int reload)
        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 @@ static int cdr_toggle_runtime_options(void)
        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 @@ int ast_cdr_engine_init(void)
        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 @@ void ast_cdr_engine_term(void)
        }
 }
 
-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 @@ int ast_cdr_engine_reload(void)
        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,
+);
index 2813e60c4caeac6adc5caad315552a779764c3be..91c625a3c268ce892723bc2997799458ae7ef968 100644 (file)
@@ -38,7 +38,7 @@
 
 #include "asterisk.h"
 
-#include "asterisk/_private.h"
+#include "asterisk/module.h"
 
 #include "asterisk/channel.h"
 #include "asterisk/pbx.h"
@@ -1421,7 +1421,7 @@ static void destroy_subscriptions(void)
        cel_cel_forwarder = stasis_forward_cancel(cel_cel_forwarder);
 }
 
-static void cel_engine_cleanup(void)
+static int unload_module(void)
 {
        destroy_routes();
        destroy_subscriptions();
@@ -1433,6 +1433,8 @@ static void cel_engine_cleanup(void)
        ao2_global_obj_release(cel_dialstatus_store);
        ao2_global_obj_release(cel_linkedids);
        ao2_global_obj_release(cel_backends);
+
+       return 0;
 }
 
 /*!
@@ -1555,7 +1557,7 @@ static int create_routes(void)
 AO2_STRING_FIELD_HASH_FN(cel_linkedid, id)
 AO2_STRING_FIELD_CMP_FN(cel_linkedid, id)
 
-int ast_cel_engine_init(void)
+static int load_module(void)
 {
        struct ao2_container *container;
 
@@ -1563,7 +1565,7 @@ int ast_cel_engine_init(void)
        ao2_global_obj_replace_unref(cel_linkedids, container);
        ao2_cleanup(container);
        if (!container) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
 
        container = ao2_container_alloc(NUM_DIALSTATUS_BUCKETS,
@@ -1571,26 +1573,26 @@ int ast_cel_engine_init(void)
        ao2_global_obj_replace_unref(cel_dialstatus_store, container);
        ao2_cleanup(container);
        if (!container) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
 
        if (STASIS_MESSAGE_TYPE_INIT(cel_generic_type)) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
 
        if (ast_cli_register(&cli_status)) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
 
        container = ao2_container_alloc(BACKEND_BUCKETS, cel_backend_hash_fn, cel_backend_cmp_fn);
        ao2_global_obj_replace_unref(cel_backends, container);
        ao2_cleanup(container);
        if (!container) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
 
        if (aco_info_init(&cel_cfg_info)) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
 
        aco_option_register(&cel_cfg_info, "enable", ACO_EXACT, general_options, "no", OPT_BOOL_T, 1, FLDSET(struct ast_cel_general_config, enable));
@@ -1602,7 +1604,7 @@ int ast_cel_engine_init(void)
                struct cel_config *cel_cfg = cel_config_alloc();
 
                if (!cel_cfg) {
-                       return -1;
+                       return AST_MODULE_LOAD_FAILURE;
                }
 
                /* We couldn't process the configuration so create a default config. */
@@ -1614,18 +1616,17 @@ int ast_cel_engine_init(void)
        }
 
        if (create_subscriptions()) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
 
        if (ast_cel_check_enabled() && create_routes()) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
 
-       ast_register_cleanup(cel_engine_cleanup);
-       return 0;
+       return AST_MODULE_LOAD_SUCCESS;
 }
 
-int ast_cel_engine_reload(void)
+static int reload_module(void)
 {
        unsigned int was_enabled = ast_cel_check_enabled();
        unsigned int is_enabled;
@@ -1745,3 +1746,11 @@ int ast_cel_backend_register(const char *name, ast_cel_backend_cb backend_callba
        ao2_ref(backend, -1);
        return 0;
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "CEL Engine",
+       .support_level = AST_MODULE_SUPPORT_CORE,
+       .load = load_module,
+       .unload = unload_module,
+       .reload = reload_module,
+       .load_pri = AST_MODPRI_CORE,
+);
index c71d19b81f92fd773cd6b2314257617b8d80282c..ebd39c70b6663ef6c7a6a9e2afbc2904e5f18684 100644 (file)
@@ -7583,22 +7583,6 @@ static int ast_channel_hash_cb(const void *obj, const int flags)
        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).
@@ -7822,8 +7806,6 @@ int ast_channels_init(void)
 
        ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel));
 
-       ast_plc_reload();
-
        ast_register_cleanup(channels_shutdown);
 
        AST_RWLIST_HEAD_INIT(&ami_vars);
index 38192ed2523e4161678453f4e8fc3c751dafa43b..14908a50f2ceae72ed6e8a3fdacb0a70f47a4a38 100644 (file)
        <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 ";--"
@@ -2883,7 +2889,7 @@ static int ast_realtime_append_mapping(const char *name, const char *driver, con
        return 0;
 }
 
-int read_config_maps(void)
+static int reload_module(void)
 {
        struct ast_config *config, *configtmp;
        struct ast_variable *v;
@@ -4042,6 +4048,7 @@ static void config_shutdown(void)
 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;
 }
@@ -4128,3 +4135,26 @@ int ast_config_hook_register(const char *name,
        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,
+);
index 0e5efd6da63bedf5da259c5c27f78fcadc12c6c0..c25b601b335e34a0fc699c62774e41009e651612 100644 (file)
@@ -49,6 +49,7 @@
 #include <regex.h>
 #include <signal.h>
 
+#include "asterisk/module.h"
 #include "asterisk/dnsmgr.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/utils.h"
@@ -406,7 +407,7 @@ static struct ast_cli_entry cli_reload = AST_CLI_DEFINE(handle_cli_reload, "Relo
 static struct ast_cli_entry cli_refresh = AST_CLI_DEFINE(handle_cli_refresh, "Performs an immediate refresh");
 static struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the DNS manager status");
 
-static void dnsmgr_shutdown(void)
+static int unload_module(void)
 {
        ast_cli_unregister(&cli_reload);
        ast_cli_unregister(&cli_status);
@@ -424,24 +425,24 @@ static void dnsmgr_shutdown(void)
        ast_mutex_unlock(&refresh_lock);
 
        ast_sched_context_destroy(sched);
+
+       return 0;
 }
 
-int dnsmgr_init(void)
+static int load_module(void)
 {
        if (!(sched = ast_sched_context_create())) {
                ast_log(LOG_ERROR, "Unable to create schedule context.\n");
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
        ast_cli_register(&cli_reload);
        ast_cli_register(&cli_status);
        ast_cli_register(&cli_refresh);
 
-       ast_register_cleanup(dnsmgr_shutdown);
-
-       return do_reload(1);
+       return do_reload(1) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
 }
 
-int dnsmgr_reload(void)
+static int reload_module(void)
 {
        return do_reload(0);
 }
@@ -515,3 +516,11 @@ static int do_reload(int loading)
 
        return 0;
 }
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "DNS Manager",
+       .support_level = AST_MODULE_SUPPORT_CORE,
+       .load = load_module,
+       .unload = unload_module,
+       .reload = reload_module,
+       .load_pri = AST_MODPRI_CORE,
+);
index 66d95adc2bc762d3e755f5b719e37bba31849774..ea653d857b3737a75736627f76acc8f5d7774fe3 100644 (file)
@@ -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 @@ int ast_dsp_busydetect(struct ast_dsp *dsp)
 #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,31 +2394,35 @@ AST_TEST_DEFINE(test_dsp_dtmf_detect)
 }
 #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);
+
+       return 0;
 }
-#endif
 
-int ast_dsp_init(void)
+static int load_module(void)
 {
        if (_dsp_init(0)) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
 
-#ifdef TEST_FRAMEWORK
        AST_TEST_REGISTER(test_dsp_fax_detect);
        AST_TEST_REGISTER(test_dsp_dtmf_detect);
 
-       ast_register_cleanup(test_dsp_shutdown);
-#endif
-
-       return 0;
+       return 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,
+);
index 5c217c43ca2356cbe4e76b3fc1d71ebbff150cbd..a44a60cbeb6959db61a937bd9118adb533a71384 100644 (file)
@@ -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 @@ static int private_enum_init(int reload)
        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,
+);
index 35039e0fa5ba28013ec2b834fa6b765ac04c0174..3db6d397b44cffeb5dc5b046535cd75d52e6f852 100644 (file)
@@ -40,6 +40,7 @@
 #include "asterisk.h"
 
 #include "asterisk/_private.h"
+#include "features_config.h"
 
 #include <pthread.h>
 #include <signal.h>
@@ -1145,29 +1146,32 @@ done:
        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();
+       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);
 
-       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,
+);
index 195fbaceb101a7fd3b473a36dd6d61e6e2c4b9a7..f116e89d5eccc33aef180b2cf83166259bb67369 100644 (file)
@@ -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 @@ static struct ast_cli_entry cli_features_config[] = {
        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 @@ void ast_features_config_shutdown(void)
        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 @@ int ast_features_config_reload(void)
        return 0;
 }
 
-int ast_features_config_init(void)
+int load_features_config(void)
 {
        int res;
 
diff --git a/main/features_config.h b/main/features_config.h
new file mode 100644 (file)
index 0000000..8e9e4ac
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+* Asterisk -- An open source telephony toolkit.
+*
+* Copyright (C) 2018, CFWare, LLC.
+*
+* Corey Farrell <git@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_ */
index 30b2fe2c46937220b07a12344269a30839c92a5f..55d10290bac3a26849b925f49a207e478edba000 100644 (file)
@@ -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 @@ static char *handle_show_http(struct ast_cli_entry *e, int cmd, struct ast_cli_a
        return CLI_SUCCESS;
 }
 
-int ast_http_reload(void)
+static int reload_module(void)
 {
        return __ast_http_load(1);
 }
@@ -2273,7 +2273,7 @@ static struct ast_cli_entry cli_http[] = {
        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 @@ static void http_shutdown(void)
                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,
+);
index 89710584b587160a6209bbed96cbc37ef2617ffa..9b0976809e83e7fe8e01b09c30ad17f77d10e860 100644 (file)
@@ -1114,7 +1114,7 @@ static int ast_tone_zone_cmp(void *obj, void *arg, int flags)
  * \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,38 @@ static void indications_shutdown(void)
                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)
 {
        ast_tone_zones = ao2_container_alloc(NUM_TONE_ZONE_BUCKETS,
                        ast_tone_zone_hash, ast_tone_zone_cmp);
        if (!ast_tone_zones) {
-               return -1;
+               return AST_MODULE_LOAD_FAILURE;
        }
 
        if (load_indications(0)) {
-               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,
+);
index 08d9552ff095bc94b4d82edc4c2c028c5a9fe257..bc78962050cf45e5a7a3b6f7ec548a9c1929b75a 100644 (file)
 #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>
@@ -513,10 +506,11 @@ void ast_module_register(const struct ast_module_info *info)
        struct ast_module *mod;
 
        if (!loader_ready) {
-               mod = ast_calloc(1, sizeof(*mod) + strlen(info->name) + 1);
+               mod = ast_std_calloc(1, sizeof(*mod) + strlen(info->name) + 1);
                if (!mod) {
                        /* We haven't even reached main() yet, if we can't
                         * allocate memory at this point just give up. */
+                       fprintf(stderr, "Allocation failure during startup.\n");
                        exit(2);
                }
                strcpy(mod->resource, info->name); /* safe */
@@ -580,7 +574,11 @@ static void module_destroy(struct ast_module *mod)
 
        AST_LIST_HEAD_DESTROY(&mod->users);
        ao2_cleanup(mod->ref_debug);
-       ast_free(mod);
+       if (mod->flags.builtin) {
+               ast_std_free(mod);
+       } else {
+               ast_free(mod);
+       }
 }
 
 void ast_module_unregister(const struct ast_module_info *info)
@@ -690,33 +688,6 @@ void __ast_module_user_hangup_all(struct ast_module *mod)
        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 +1131,6 @@ char *ast_module_helper(const char *line, const char *word, int pos, int state,
                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 +1306,6 @@ enum ast_module_reload_result ast_module_reload(const char *name)
 {
        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
@@ -1380,22 +1340,6 @@ enum ast_module_reload_result ast_module_reload(const char *name)
                }
        }
 
-       /* 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);
        AST_DLLIST_TRAVERSE(&module_list, cur, entry) {
                const struct ast_module_info *info = cur->info;
@@ -1516,6 +1460,10 @@ static enum ast_module_load_result start_resource(struct ast_module *mod)
                }
 
                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 +1829,19 @@ int load_modules(unsigned int preload_only)
                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);
index 6060b3c4d2bcc58e6d51f82e85c8576e36cd099f..46d61ed33606d3563a694d821bdf9697b0ecac12 100644 (file)
@@ -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"
@@ -1125,16 +1126,6 @@ static int reload_logger(int rotate, const char *altconf)
        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)
 {
        switch (cmd) {
@@ -2369,3 +2360,27 @@ int ast_logger_get_queue_limit(void)
 {
        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,
+);
index b698702afa1520fd039fe2b94bb0a57254d3d13c..64b07d319e2e96f108a183dd829ac9d435d0e1df 100644 (file)
@@ -2710,6 +2710,8 @@ static char *handle_showmaneventq(struct ast_cli_entry *e, int cmd, struct ast_c
        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 @@ static char *handle_manager_reload(struct ast_cli_entry *e, int cmd, struct ast_
        if (a->argc > 2) {
                return CLI_SHOWUSAGE;
        }
-       reload_manager();
+       reload_module();
        return CLI_SUCCESS;
 }
 
@@ -8971,8 +8973,6 @@ static int __init_manager(int reload, int by_external_config)
 #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 @@ static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub,
        __init_manager(1, 1);
 }
 
-int init_manager(void)
+static int unload_module(void)
+{
+       return 0;
+}
+
+static int load_module(void)
 {
-       return __init_manager(0, 0);
+       ast_register_cleanup(manager_shutdown);
+
+       return __init_manager(0, 0) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
 }
 
-int reload_manager(void)
+static int reload_module(void)
 {
        return __init_manager(1, 0);
 }
@@ -9557,3 +9564,12 @@ ast_manager_event_blob_create(
 
        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",
+);
index 3a4c45401e4f95cb87b83e036172583104e36587..4f2069a757f2585625ef79365ff9074e4bd3f9e2 100644 (file)
  * Olle E. Johansson <oej@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"
@@ -395,36 +400,6 @@ publish_failure:
        return -1;
 }
 
-/*!
- * \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)
@@ -552,32 +527,64 @@ static struct ast_cli_entry cli_named_acl[] = {
        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));
-
-       STASIS_MESSAGE_TYPE_INIT(ast_named_acl_change_type);
-
-       ast_register_cleanup(named_acl_cleanup);
-
        if (aco_info_init(&cfg_info)) {
-               return 0;
+               return AST_MODULE_LOAD_FAILURE;
        }
 
+       STASIS_MESSAGE_TYPE_INIT(ast_named_acl_change_type);
+
        /* 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));
        aco_option_register(&cfg_info, "deny", ACO_EXACT, named_acl_types, NULL, OPT_ACL_T, 0, FLDSET(struct named_acl, ha));
 
        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,
+);
index 2a8279f46deaebd86ffa1283e7ba3795cbaf2841..847ce65b0b85fc90326fc3efb52889bca2afc1ab 100644 (file)
@@ -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 @@ plc_state_t *plc_init(plc_state_t *s)
 }
 /*- 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,
+);
index c792c1bbd296a9aea80428eea6658e369b56eb41..08e29275ec9a8955c82f6b239459c1b61b815c4a 100644 (file)
@@ -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 @@ static int update_index_cb(void *obj, void *arg, int flags)
 
 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 @@ static struct ast_cli_entry cli_sounds[] = {
        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 @@ static void format_update_cb(void *data, struct stasis_subscription *sub,
 {
        /* 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 @@ int ast_sounds_index_init(void)
                        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,
+);
index 5a491e65cd29a5230c907d03a84d913966bce010..f6cd3b90a1df0a8411c6f3cab391695dec3967e6 100644 (file)
@@ -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 @@ static int udptl_pre_apply_config(void) {
        return 0;
 }
 
-int ast_udptl_reload(void)
+static int reload_module(void)
 {
        __ast_udptl_reload(1);
+
        return 0;
 }
 
@@ -1365,17 +1367,19 @@ int ast_udptl_reload(void)
  * \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 @@ void ast_udptl_init(void)
 
        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,
+);
index 5ffb5833f101d736d0a89ca59f5f64f87c361274..354201bf3095f0cbcef5a0509d5d1d11958a831c 100644 (file)
@@ -1196,6 +1196,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_
        .unload = unload_module,
        .reload = reload_module,
        .optional_modules = "res_http_websocket",
-       .requires = "res_stasis",
+       .requires = "http,res_stasis",
        .load_pri = AST_MODPRI_APP_DEPEND,
 );
index 03f0338ccafc7d0a85296362f8c2cac11078146a..03ff80c2ed9d7248043656b35fabb3af24a0419f 100644 (file)
@@ -650,5 +650,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Realtime Curl configu
        .unload = unload_module,
        .reload = reload_module,
        .load_pri = AST_MODPRI_REALTIME_DRIVER,
-       .requires = "res_curl,func_curl",
+       .requires = "extconfig,res_curl,func_curl",
 );
index 15d9ec018bff9d2938e7baff8f24a229f979aa75..d73f42b1159559310dd6d757ace86ee3f95c9190 100644 (file)
@@ -1999,4 +1999,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "LDAP realtime interfa
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_REALTIME_DRIVER,
+       .requires = "extconfig",
 );
index 5d6c2c60a797f056e5f31d225a3a6aeea8e10681..be920d673f27e612a76eaff5f9357d90960c0915 100644 (file)
@@ -1238,4 +1238,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Realtime ODBC configu
        .unload = unload_module,
        .reload = reload_module,
        .load_pri = AST_MODPRI_REALTIME_DRIVER,
+       .requires = "extconfig,res_odbc",
 );
index c259b30c1a8cb4b4c064bbea5024fb473d1777e8..c8660fb3a45cc81551a517eb7ac92d6f4e859b4b 100644 (file)
@@ -1720,4 +1720,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PostgreSQL RealTime C
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_REALTIME_DRIVER,
+       .requires = "extconfig",
 );
index af3b12449453de8e16bd6eeac37a78f91c16aaa3..323d2249b2841ca90daf9bbf9e40b5e7453dc8a5 100644 (file)
@@ -1772,9 +1772,16 @@ static int load_module(void)
        return AST_MODULE_LOAD_SUCCESS;
 }
 
+/*
+ * This module should require "cdr" to enforce startup/shutdown ordering but it
+ * loads at REALTIME_DRIVER priority which would cause "cdr" to load too early.
+ *
+ * ast_cdr_register / ast_cdr_unregister is safe for use while "cdr" is not running.
+ */
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Realtime SQLite configuration",
        .support_level = AST_MODULE_SUPPORT_DEPRECATED,
        .load = load_module,
        .unload = unload_module,
        .load_pri = AST_MODPRI_REALTIME_DRIVER,
+       .requires = "extconfig",
 );
index de2de1ce4d9f2d0031c063aec14c49c08444842d..854034f38fae7371f38647d83fda6e91f5e93503 100644 (file)
@@ -1393,4 +1393,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SQLite 3 realtime con
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_REALTIME_DRIVER,
+       .requires = "extconfig",
 );
index f36b772d48cfdc4f4bf53e4a82e01a5d36e88965..bf404ced6a884d9a29a8d46856b40c70bd74aeb9 100644 (file)
@@ -513,4 +513,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "HTTP POST support",
        .load = load_module,
        .unload = unload_module,
        .reload = reload,
+       .requires = "http",
 );
index 223bb2dd816077b73c69226f3babadf3f8667f81..9a32bf37ccecfd919b44fcf9cc7ce9d0f3fa24e5 100644 (file)
@@ -1478,4 +1478,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_
        .load = load_module,
        .unload = unload_module,
        .load_pri = AST_MODPRI_CHANNEL_DEPEND,
+       .requires = "http",
 );
index 585056b75573079e282b1b9ebaca3ea09b42160f..70e13332892c192424926d4a1ed60a1ee55ea8cb 100644 (file)
@@ -1498,6 +1498,7 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_
        .unload = unload_module,
        .reload = reload,
        .load_pri = AST_MODPRI_CHANNEL_DEPEND,
+       .requires = "http",
 );
 
 /****  Public API for register/unregister, set defaults, and add extension. ****/
index 9f6b5d115e6b283410a190c1c614a3d19d18df0c..935a5598e732aeb96adf8556abb6ce77f78eea31 100644 (file)
@@ -5213,6 +5213,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_
        .unload = unload_module,
        .reload = reload_module,
        .load_pri = AST_MODPRI_CHANNEL_DEPEND - 5,
-       .requires = "res_pjproject",
+       .requires = "dnsmgr,res_pjproject",
        .optional_modules = "res_statsd",
 );
index 249472ba94d1bc02e81b6042d5f09272b470c2e6..333295fe6540378de466116a58384ef0ece0362d 100644 (file)
@@ -1048,5 +1048,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP T.38 UDPTL Supp
        .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",
 );