summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2017-04-11 10:07:39 -0600
committerGeorge Joseph <gjoseph@digium.com>2017-04-12 15:57:21 -0600
commit747beb1ed159f89a3b58742e4257740b3d6d6bba (patch)
tree3ba17dd62d0270a9ee976f173f948304b1733773 /res
parent60fd01f7f4b43515f5d4d915eec701c6054c53cf (diff)
modules: change module LOAD_FAILUREs to LOAD_DECLINES
In all non-pbx modules, AST_MODULE_LOAD_FAILURE has been changed to AST_MODULE_LOAD_DECLINE. This prevents asterisk from exiting if a module can't be loaded. If the user wishes to retain the FAILURE behavior for a specific module, they can use the "require" or "preload-require" keyword in modules.conf. A new API was added to logger: ast_is_logger_initialized(). This allows asterisk.c/check_init() to print to the error log once the logger subsystem is ready instead of just to stdout. If something does fail before the logger is initialized, we now print to stderr instead of stdout. Change-Id: I5f4b50623d9b5a6cb7c5624a8c5c1274c13b2b25
Diffstat (limited to 'res')
-rw-r--r--res/res_ari.c51
-rw-r--r--res/res_ari_events.c29
-rw-r--r--res/res_ari_model.c2
-rw-r--r--res/res_calendar.c6
-rw-r--r--res/res_chan_stats.c23
-rw-r--r--res/res_config_sqlite.c16
-rw-r--r--res/res_config_sqlite3.c6
-rw-r--r--res/res_endpoint_stats.c2
-rw-r--r--res/res_hep_rtcp.c2
-rw-r--r--res/res_http_websocket.c2
-rw-r--r--res/res_limit.c2
-rw-r--r--res/res_pjsip/config_transport.c2
-rw-r--r--res/res_pjsip_nat.c4
-rw-r--r--res/res_pjsip_one_touch_record_info.c2
-rw-r--r--res/res_pjsip_outbound_publish.c2
-rw-r--r--res/res_pjsip_outbound_registration.c8
-rw-r--r--res/res_pjsip_pubsub.c12
-rw-r--r--res/res_pjsip_sdp_rtp.c2
-rw-r--r--res/res_pjsip_send_to_voicemail.c2
-rw-r--r--res/res_pjsip_t38.c2
-rw-r--r--res/res_smdi.c4
-rw-r--r--res/res_stasis.c4
-rw-r--r--res/res_stasis_device_state.c5
-rw-r--r--res/res_stasis_playback.c5
-rw-r--r--res/res_stasis_recording.c5
-rw-r--r--res/res_stasis_test.c2
-rw-r--r--res/res_statsd.c3
27 files changed, 110 insertions, 95 deletions
diff --git a/res/res_ari.c b/res/res_ari.c
index 549d78353..054d3bf3c 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -1106,6 +1106,27 @@ static struct ast_http_uri http_uri = {
.no_decode_uri = 1,
};
+static int unload_module(void)
+{
+ ast_ari_cli_unregister();
+
+ if (is_enabled()) {
+ ast_debug(3, "Disabling ARI\n");
+ ast_http_uri_unlink(&http_uri);
+ }
+
+ ast_ari_config_destroy();
+
+ ao2_cleanup(root_handler);
+ root_handler = NULL;
+ ast_mutex_destroy(&root_handler_lock);
+
+ ast_json_unref(oom_json);
+ oom_json = NULL;
+
+ return 0;
+}
+
static int load_module(void)
{
ast_mutex_init(&root_handler_lock);
@@ -1115,7 +1136,7 @@ static int load_module(void)
root_handler = root_handler_create();
}
if (!root_handler) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
/* oom_json may have been built during a declined load */
@@ -1125,10 +1146,12 @@ static int load_module(void)
}
if (!oom_json) {
/* Ironic */
- return AST_MODULE_LOAD_FAILURE;
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_ari_config_init() != 0) {
+ unload_module();
return AST_MODULE_LOAD_DECLINE;
}
@@ -1140,33 +1163,13 @@ static int load_module(void)
}
if (ast_ari_cli_register() != 0) {
- return AST_MODULE_LOAD_FAILURE;
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
}
-static int unload_module(void)
-{
- ast_ari_cli_unregister();
-
- if (is_enabled()) {
- ast_debug(3, "Disabling ARI\n");
- ast_http_uri_unlink(&http_uri);
- }
-
- ast_ari_config_destroy();
-
- ao2_cleanup(root_handler);
- root_handler = NULL;
- ast_mutex_destroy(&root_handler_lock);
-
- ast_json_unref(oom_json);
- oom_json = NULL;
-
- return 0;
-}
-
static int reload_module(void)
{
char was_enabled = is_enabled();
diff --git a/res/res_ari_events.c b/res/res_ari_events.c
index 8ccb8870c..8d8a303d1 100644
--- a/res/res_ari_events.c
+++ b/res/res_ari_events.c
@@ -417,6 +417,15 @@ static struct stasis_rest_handlers events = {
.children = { &events_user, }
};
+static int unload_module(void)
+{
+ ast_ari_remove_handler(&events);
+ ao2_cleanup(events.ws_server);
+ events.ws_server = NULL;
+ stasis_app_unref();
+ return 0;
+}
+
static int load_module(void)
{
int res = 0;
@@ -428,31 +437,27 @@ static int load_module(void)
events.ws_server = ast_websocket_server_create();
if (!events.ws_server) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
protocol = ast_websocket_sub_protocol_alloc("ari");
if (!protocol) {
ao2_ref(events.ws_server, -1);
events.ws_server = NULL;
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
protocol->session_attempted = ast_ari_events_event_websocket_ws_attempted_cb;
protocol->session_established = ast_ari_events_event_websocket_ws_established_cb;
res |= ast_websocket_server_add_protocol2(events.ws_server, protocol);
stasis_app_ref();
res |= ast_ari_add_handler(&events);
- return res;
-}
-static int unload_module(void)
-{
- ast_ari_remove_handler(&events);
- ao2_cleanup(events.ws_server);
- events.ws_server = NULL;
- ast_ari_websocket_events_event_websocket_dtor();
- stasis_app_unref();
- return 0;
+ if (res) {
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
+ }
+
+ return AST_MODULE_LOAD_SUCCESS;
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - WebSocket resource",
diff --git a/res/res_ari_model.c b/res/res_ari_model.c
index dd8e1af38..015b1e73f 100644
--- a/res/res_ari_model.c
+++ b/res/res_ari_model.c
@@ -190,7 +190,7 @@ static int load_module(void)
REG_EXTENDED | REG_ICASE | REG_NOSUB);
if (res != 0) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/res_calendar.c b/res/res_calendar.c
index 92b73c1ed..666b0e184 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -1888,7 +1888,7 @@ static int load_module(void)
{
if (!(calendars = ao2_container_alloc(CALENDAR_BUCKETS, calendar_hash_fn, calendar_cmp_fn))) {
ast_log(LOG_ERROR, "Unable to allocate calendars container!\n");
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (load_config(0)) {
@@ -1902,7 +1902,9 @@ static int load_module(void)
if (!(sched = ast_sched_context_create())) {
ast_log(LOG_ERROR, "Unable to create sched context\n");
- return AST_MODULE_LOAD_FAILURE;
+ ast_config_destroy(calendar_config);
+ calendar_config = NULL;
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_pthread_create_background(&refresh_thread, NULL, do_refresh, NULL) < 0) {
diff --git a/res/res_chan_stats.c b/res/res_chan_stats.c
index 9a26db78c..061d0867e 100644
--- a/res/res_chan_stats.c
+++ b/res/res_chan_stats.c
@@ -148,13 +148,22 @@ static void default_route(void *data, struct stasis_subscription *sub,
}
}
+static int unload_module(void)
+{
+ stasis_unsubscribe_and_join(sub);
+ sub = NULL;
+ stasis_message_router_unsubscribe_and_join(router);
+ router = NULL;
+ return 0;
+}
+
static int load_module(void)
{
/* You can create a message router to route messages by type */
router = stasis_message_router_create(
ast_channel_topic_all_cached());
if (!router) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
stasis_message_router_add(router, stasis_cache_update_type(),
updates, NULL);
@@ -163,20 +172,12 @@ static int load_module(void)
/* Or a subscription to receive all of the messages from a topic */
sub = stasis_subscribe(ast_channel_topic_all(), statsmaker, NULL);
if (!sub) {
- return AST_MODULE_LOAD_FAILURE;
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
}
-static int unload_module(void)
-{
- stasis_unsubscribe_and_join(sub);
- sub = NULL;
- stasis_message_router_unsubscribe_and_join(router);
- router = NULL;
- return 0;
-}
-
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Example of how to use Stasis",
.support_level = AST_MODULE_SUPPORT_EXTENDED,
.load = load_module,
diff --git a/res/res_config_sqlite.c b/res/res_config_sqlite.c
index 96a10b43f..0f9113188 100644
--- a/res/res_config_sqlite.c
+++ b/res/res_config_sqlite.c
@@ -1680,7 +1680,7 @@ static int load_module(void)
ast_log(LOG_ERROR, "%s\n", S_OR(errormsg, sqlite_error_string(error)));
sqlite_freemem(errormsg);
unload_module();
- return 1;
+ return AST_MODULE_LOAD_DECLINE;
}
sqlite_freemem(errormsg);
@@ -1700,7 +1700,7 @@ static int load_module(void)
if (!query) {
ast_log(LOG_ERROR, "Unable to allocate SQL query\n");
unload_module();
- return 1;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_debug(1, "SQL query: %s\n", query);
@@ -1719,7 +1719,7 @@ static int load_module(void)
ast_log(LOG_ERROR, "%s\n", S_OR(errormsg, sqlite_error_string(error)));
sqlite_freemem(errormsg);
unload_module();
- return 1;
+ return AST_MODULE_LOAD_DECLINE;
}
sqlite_freemem(errormsg);
@@ -1729,7 +1729,7 @@ static int load_module(void)
if (!query) {
ast_log(LOG_ERROR, "Unable to allocate SQL query\n");
unload_module();
- return 1;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_debug(1, "SQL query: %s\n", query);
@@ -1744,7 +1744,7 @@ static int load_module(void)
ast_log(LOG_ERROR, "%s\n", S_OR(errormsg, sqlite_error_string(error)));
sqlite_freemem(errormsg);
unload_module();
- return 1;
+ return AST_MODULE_LOAD_DECLINE;
}
}
sqlite_freemem(errormsg);
@@ -1754,7 +1754,7 @@ static int load_module(void)
if (error) {
unload_module();
- return 1;
+ return AST_MODULE_LOAD_DECLINE;
}
cdr_registered = 1;
@@ -1764,12 +1764,12 @@ static int load_module(void)
if (error) {
unload_module();
- return 1;
+ return AST_MODULE_LOAD_DECLINE;
}
cli_status_registered = 1;
- return 0;
+ return AST_MODULE_LOAD_SUCCESS;
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Realtime SQLite configuration",
diff --git a/res/res_config_sqlite3.c b/res/res_config_sqlite3.c
index 087843a68..0025548be 100644
--- a/res/res_config_sqlite3.c
+++ b/res/res_config_sqlite3.c
@@ -1359,18 +1359,18 @@ static int load_module(void)
discover_sqlite3_caps();
if (!((databases = ao2_container_alloc(DB_BUCKETS, db_hash_fn, db_cmp_fn)))) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (parse_config(0)) {
ao2_ref(databases, -1);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(ast_config_engine_register(&sqlite3_config_engine))) {
ast_log(LOG_ERROR, "The config API must have changed, this shouldn't happen.\n");
ao2_ref(databases, -1);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
diff --git a/res/res_endpoint_stats.c b/res/res_endpoint_stats.c
index 249cbea9b..1e3f104c2 100644
--- a/res/res_endpoint_stats.c
+++ b/res/res_endpoint_stats.c
@@ -118,7 +118,7 @@ static int load_module(void)
router = stasis_message_router_create(ast_endpoint_topic_all_cached());
if (!router) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
stasis_message_router_add(router, stasis_cache_update_type(), cache_update_cb, NULL);
diff --git a/res/res_hep_rtcp.c b/res/res_hep_rtcp.c
index 25b90c7a2..7191f4661 100644
--- a/res/res_hep_rtcp.c
+++ b/res/res_hep_rtcp.c
@@ -155,7 +155,7 @@ static int load_module(void)
stasis_rtp_subscription = stasis_subscribe(ast_rtp_topic(),
rtp_topic_handler, NULL);
if (!stasis_rtp_subscription) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index 799eb848f..60332f591 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -1441,7 +1441,7 @@ static int load_module(void)
{
websocketuri.data = websocket_server_internal_create();
if (!websocketuri.data) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_http_uri_link(&websocketuri);
websocket_add_protocol_internal("echo", websocket_echo_callback);
diff --git a/res/res_limit.c b/res/res_limit.c
index bff777d99..a308c4121 100644
--- a/res/res_limit.c
+++ b/res/res_limit.c
@@ -209,7 +209,7 @@ static int unload_module(void)
static int load_module(void)
{
- return ast_cli_register(&cli_ulimit) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
+ return ast_cli_register(&cli_ulimit) ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Resource limits");
diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c
index d180296f4..62bc9d67d 100644
--- a/res/res_pjsip/config_transport.c
+++ b/res/res_pjsip/config_transport.c
@@ -1348,7 +1348,7 @@ int ast_sip_initialize_sorcery_transport(void)
transport_states = ao2_container_alloc(DEFAULT_STATE_BUCKETS, internal_state_hash, internal_state_cmp);
if (!transport_states) {
ast_log(LOG_ERROR, "Unable to allocate transport states container\n");
- return AST_MODULE_LOAD_FAILURE;
+ return -1;
}
ast_sorcery_apply_default(sorcery, "transport", "config", "pjsip.conf,criteria=type=transport");
diff --git a/res/res_pjsip_nat.c b/res/res_pjsip_nat.c
index a26180bc0..9205622d7 100644
--- a/res/res_pjsip_nat.c
+++ b/res/res_pjsip_nat.c
@@ -361,13 +361,13 @@ static int load_module(void)
if (ast_sip_register_service(&nat_module)) {
ast_log(LOG_ERROR, "Could not register NAT module for incoming and outgoing requests\n");
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_sip_session_register_supplement(&nat_supplement)) {
ast_log(LOG_ERROR, "Could not register NAT session supplement for incoming and outgoing INVITE requests\n");
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
diff --git a/res/res_pjsip_one_touch_record_info.c b/res/res_pjsip_one_touch_record_info.c
index 2d53fd48e..ec5f9be3e 100644
--- a/res/res_pjsip_one_touch_record_info.c
+++ b/res/res_pjsip_one_touch_record_info.c
@@ -112,7 +112,7 @@ static int load_module(void)
if (ast_sip_session_register_supplement(&info_supplement)) {
ast_log(LOG_ERROR, "Unable to register One Touch Recording supplement\n");
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
diff --git a/res/res_pjsip_outbound_publish.c b/res/res_pjsip_outbound_publish.c
index a19a9bb24..c413cb0e1 100644
--- a/res/res_pjsip_outbound_publish.c
+++ b/res/res_pjsip_outbound_publish.c
@@ -1631,7 +1631,7 @@ static int load_module(void)
shutdown_group = ast_serializer_shutdown_group_alloc();
if (!shutdown_group) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_sorcery_apply_config(ast_sip_get_sorcery(), "res_pjsip_outbound_publish");
diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 704239bd0..8a840ff05 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -2082,7 +2082,7 @@ static int load_module(void)
shutdown_group = ast_serializer_shutdown_group_alloc();
if (!shutdown_group) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
/* Create outbound registration states container. */
@@ -2091,7 +2091,7 @@ static int load_module(void)
if (!new_states) {
ast_log(LOG_ERROR, "Unable to allocate registration states container\n");
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ao2_global_obj_replace_unref(current_states, new_states);
ao2_ref(new_states, -1);
@@ -2135,7 +2135,7 @@ static int load_module(void)
&registration_observer)) {
ast_log(LOG_ERROR, "Unable to register observers.\n");
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
/* Register how this module identifies endpoints. */
@@ -2146,7 +2146,7 @@ static int load_module(void)
if (!cli_formatter) {
ast_log(LOG_ERROR, "Unable to allocate memory for cli formatter\n");
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
cli_formatter->name = "registration";
cli_formatter->print_header = cli_print_header;
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index f0467627e..a1f3f2462 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -5225,13 +5225,13 @@ static int load_module(void)
if (!(sched = ast_sched_context_create())) {
ast_log(LOG_ERROR, "Could not create scheduler for publication expiration\n");
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_sched_start_thread(sched)) {
ast_log(LOG_ERROR, "Could not start scheduler thread for publication expiration\n");
ast_sched_context_destroy(sched);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), NULL, PJSIP_H_ALLOW, NULL, 1, &str_PUBLISH);
@@ -5239,7 +5239,7 @@ static int load_module(void)
if (ast_sip_register_service(&pubsub_module)) {
ast_log(LOG_ERROR, "Could not register pubsub service\n");
ast_sched_context_destroy(sched);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_sorcery_apply_config(sorcery, "res_pjsip_pubsub");
@@ -5249,7 +5249,7 @@ static int load_module(void)
ast_log(LOG_ERROR, "Could not register subscription persistence object support\n");
ast_sip_unregister_service(&pubsub_module);
ast_sched_context_destroy(sched);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_sorcery_object_field_register(sorcery, "subscription_persistence", "packet", "", OPT_CHAR_ARRAY_T, 0,
CHARFLDSET(struct subscription_persistence, packet));
@@ -5277,7 +5277,7 @@ static int load_module(void)
if (apply_list_configuration(sorcery)) {
ast_sip_unregister_service(&pubsub_module);
ast_sched_context_destroy(sched);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_sorcery_apply_default(sorcery, "inbound-publication", "config", "pjsip.conf,criteria=type=inbound-publication");
@@ -5286,7 +5286,7 @@ static int load_module(void)
ast_log(LOG_ERROR, "Could not register subscription persistence object support\n");
ast_sip_unregister_service(&pubsub_module);
ast_sched_context_destroy(sched);
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_sorcery_object_field_register(sorcery, "inbound-publication", "type", "", OPT_NOOP_T, 0, 0);
ast_sorcery_object_field_register_custom(sorcery, "inbound-publication", "endpoint", "",
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index 7c861dac9..dfa6957c7 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -1650,7 +1650,7 @@ static int load_module(void)
end:
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP SDP RTP/AVP stream handler",
diff --git a/res/res_pjsip_send_to_voicemail.c b/res/res_pjsip_send_to_voicemail.c
index bd70bcfd7..1cd28ceac 100644
--- a/res/res_pjsip_send_to_voicemail.c
+++ b/res/res_pjsip_send_to_voicemail.c
@@ -219,7 +219,7 @@ static int load_module(void)
if (ast_sip_session_register_supplement(&refer_supplement)) {
ast_log(LOG_ERROR, "Unable to register Send to Voicemail supplement\n");
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c
index bae4ff1dc..4f082d714 100644
--- a/res/res_pjsip_t38.c
+++ b/res/res_pjsip_t38.c
@@ -938,7 +938,7 @@ static int load_module(void)
end:
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP T.38 UDPTL Support",
diff --git a/res/res_smdi.c b/res/res_smdi.c
index 4c7a45164..e2e5b17ba 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -1126,7 +1126,7 @@ static int smdi_load(int reload)
if (!AST_LIST_EMPTY(&mwi_monitor.mailbox_mappings) && mwi_monitor.thread == AST_PTHREADT_NULL
&& ast_pthread_create_background(&mwi_monitor.thread, NULL, mwi_monitor_handler, NULL)) {
ast_log(LOG_ERROR, "Failed to start MWI monitoring thread. This module will not operate.\n");
- return AST_MODULE_LOAD_FAILURE;
+ return -1;
}
if (ao2_container_count(new_ifaces)) {
@@ -1369,7 +1369,7 @@ static int load_module(void)
res = smdi_load(0);
if (res < 0) {
_unload_module(1);
- return res;
+ return AST_MODULE_LOAD_DECLINE;
} else if (res == 1) {
_unload_module(1);
ast_log(LOG_NOTICE, "No SMDI interfaces are available to listen on, not starting SMDI listener.\n");
diff --git a/res/res_stasis.c b/res/res_stasis.c
index 196720984..9ea0d63fe 100644
--- a/res/res_stasis.c
+++ b/res/res_stasis.c
@@ -2111,12 +2111,12 @@ static int load_module(void)
37, bridges_channel_hash_fn, bridges_channel_sort_fn, NULL);
if (!apps_registry || !app_controls || !app_bridges || !app_bridges_moh || !app_bridges_playback) {
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (messaging_init()) {
unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
bridge_stasis_init();
diff --git a/res/res_stasis_device_state.c b/res/res_stasis_device_state.c
index e16bd8edd..344cb40c9 100644
--- a/res/res_stasis_device_state.c
+++ b/res/res_stasis_device_state.c
@@ -453,13 +453,14 @@ static int load_module(void)
populate_cache();
if (ast_devstate_prov_add(DEVICE_STATE_PROVIDER_STASIS,
stasis_device_state_cb)) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(device_state_subscriptions = ao2_container_alloc(
DEVICE_STATE_BUCKETS, device_state_subscriptions_hash,
device_state_subscriptions_cmp))) {
- return AST_MODULE_LOAD_FAILURE;
+ ast_devstate_prov_del(DEVICE_STATE_PROVIDER_STASIS);
+ return AST_MODULE_LOAD_DECLINE;
}
stasis_app_register_event_source(&device_state_event_source);
diff --git a/res/res_stasis_playback.c b/res/res_stasis_playback.c
index 4370f1712..c6f21365b 100644
--- a/res/res_stasis_playback.c
+++ b/res/res_stasis_playback.c
@@ -731,13 +731,14 @@ static int load_module(void)
r = STASIS_MESSAGE_TYPE_INIT(stasis_app_playback_snapshot_type);
if (r != 0) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
playbacks = ao2_container_alloc(PLAYBACK_BUCKETS, playback_hash,
playback_cmp);
if (!playbacks) {
- return AST_MODULE_LOAD_FAILURE;
+ STASIS_MESSAGE_TYPE_CLEANUP(stasis_app_playback_snapshot_type);
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/res_stasis_recording.c b/res/res_stasis_recording.c
index 630205c34..56984cb40 100644
--- a/res/res_stasis_recording.c
+++ b/res/res_stasis_recording.c
@@ -631,13 +631,14 @@ static int load_module(void)
r = STASIS_MESSAGE_TYPE_INIT(stasis_app_recording_snapshot_type);
if (r != 0) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
recordings = ao2_container_alloc(RECORDING_BUCKETS, recording_hash,
recording_cmp);
if (!recordings) {
- return AST_MODULE_LOAD_FAILURE;
+ STASIS_MESSAGE_TYPE_CLEANUP(stasis_app_recording_snapshot_type);
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/res/res_stasis_test.c b/res/res_stasis_test.c
index 8b5bad7ae..19d2a42c6 100644
--- a/res/res_stasis_test.c
+++ b/res/res_stasis_test.c
@@ -272,7 +272,7 @@ static int unload_module(void)
static int load_module(void)
{
if (STASIS_MESSAGE_TYPE_INIT(stasis_test_message_type) != 0) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
diff --git a/res/res_statsd.c b/res/res_statsd.c
index 22c4ba2e7..3d7dd1684 100644
--- a/res/res_statsd.c
+++ b/res/res_statsd.c
@@ -349,7 +349,8 @@ static int load_module(void)
}
if (statsd_init() != 0) {
- return AST_MODULE_LOAD_FAILURE;
+ aco_info_destroy(&cfg_info);
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;