summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
Diffstat (limited to 'res')
-rw-r--r--res/res_ari.c51
-rw-r--r--res/res_ari_events.c28
-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, 94 deletions
diff --git a/res/res_ari.c b/res/res_ari.c
index c6f81dcef..809b7f65a 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -1103,6 +1103,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);
@@ -1112,7 +1133,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 */
@@ -1122,10 +1143,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;
}
@@ -1137,33 +1160,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 d102428bb..461b31404 100644
--- a/res/res_ari_events.c
+++ b/res/res_ari_events.c
@@ -418,6 +418,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;
@@ -425,30 +434,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;
- 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 96cab8096..e372bcf9c 100644
--- a/res/res_ari_model.c
+++ b/res/res_ari_model.c
@@ -192,7 +192,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 264165470..3725c9435 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -1882,7 +1882,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)) {
@@ -1896,7 +1896,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 8d446b3b3..9104e0e04 100644
--- a/res/res_chan_stats.c
+++ b/res/res_chan_stats.c
@@ -150,13 +150,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);
@@ -165,20 +174,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 a5a831ea3..fa45fec35 100644
--- a/res/res_config_sqlite.c
+++ b/res/res_config_sqlite.c
@@ -1681,7 +1681,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);
@@ -1701,7 +1701,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);
@@ -1720,7 +1720,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);
@@ -1730,7 +1730,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);
@@ -1745,7 +1745,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);
@@ -1755,7 +1755,7 @@ static int load_module(void)
if (error) {
unload_module();
- return 1;
+ return AST_MODULE_LOAD_DECLINE;
}
cdr_registered = 1;
@@ -1765,12 +1765,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 5362e9ede..56558624f 100644
--- a/res/res_config_sqlite3.c
+++ b/res/res_config_sqlite3.c
@@ -1361,18 +1361,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 6b8479433..e2b4ffa2e 100644
--- a/res/res_endpoint_stats.c
+++ b/res/res_endpoint_stats.c
@@ -120,7 +120,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 d77b19c92..f4f1dfe3b 100644
--- a/res/res_hep_rtcp.c
+++ b/res/res_hep_rtcp.c
@@ -157,7 +157,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 71d838ad9..f49a3573e 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -1434,7 +1434,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 e883ff383..5f61f1b09 100644
--- a/res/res_limit.c
+++ b/res/res_limit.c
@@ -211,7 +211,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 5fcab6378..a0ce2a9d1 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 e15b0d815..3cac25a2d 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 0273c6a68..f84f11819 100644
--- a/res/res_pjsip_outbound_publish.c
+++ b/res/res_pjsip_outbound_publish.c
@@ -1269,7 +1269,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 ee1894ffb..0a65e6e1d 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -2083,7 +2083,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. */
@@ -2092,7 +2092,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);
@@ -2136,7 +2136,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. */
@@ -2147,7 +2147,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 79a4a8c3e..fbb1ad4e8 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -5285,13 +5285,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);
@@ -5299,7 +5299,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");
@@ -5309,7 +5309,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));
@@ -5337,7 +5337,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");
@@ -5346,7 +5346,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 e1f0cee9d..cafbd52ec 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -1628,7 +1628,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 12d6b74f6..6107a1512 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 16d50cd27..04774190e 100644
--- a/res/res_pjsip_t38.c
+++ b/res/res_pjsip_t38.c
@@ -940,7 +940,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 7a63fe46a..f4804c7cb 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -1128,7 +1128,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)) {
@@ -1371,7 +1371,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 55240bacc..9d7bc4c24 100644
--- a/res/res_stasis.c
+++ b/res/res_stasis.c
@@ -2097,12 +2097,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 2065c36b6..29e75660c 100644
--- a/res/res_stasis_device_state.c
+++ b/res/res_stasis_device_state.c
@@ -455,13 +455,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 7fdb5d4ad..57d1fd258 100644
--- a/res/res_stasis_playback.c
+++ b/res/res_stasis_playback.c
@@ -664,13 +664,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 46bc6eb71..5508be888 100644
--- a/res/res_stasis_recording.c
+++ b/res/res_stasis_recording.c
@@ -633,13 +633,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 9860b0ebd..fe015ec73 100644
--- a/res/res_stasis_test.c
+++ b/res/res_stasis_test.c
@@ -273,7 +273,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 4eb526071..eb0dc6702 100644
--- a/res/res_statsd.c
+++ b/res/res_statsd.c
@@ -351,7 +351,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;