[Asterisk-code-review] modules: change module LOAD FAILUREs to LOAD DECLINES (14) (asterisk[14])

George Joseph asteriskteam at digium.com
Wed Apr 12 07:48:32 CDT 2017


George Joseph has uploaded a new change for review. ( https://gerrit.asterisk.org/5456 )

Change subject: modules:  change module LOAD_FAILUREs to LOAD_DECLINES (14)
......................................................................

modules:  change module LOAD_FAILUREs to LOAD_DECLINES (14)

Change-Id: If99e3b4fc2d7e86fc3e61182aa6c835b407ed49e
---
M formats/format_ogg_speex.c
M res/res_ari_events.c
M res/res_http_media_cache.c
M rest-api-templates/res_ari_resource.c.mustache
M tests/test_media_cache.c
5 files changed, 20 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/56/5456/1

diff --git a/formats/format_ogg_speex.c b/formats/format_ogg_speex.c
index 6152e9c..52ac7cf 100644
--- a/formats/format_ogg_speex.c
+++ b/formats/format_ogg_speex.c
@@ -314,6 +314,15 @@
 	.desc_size = sizeof(struct speex_desc),
 };
 
+static int unload_module(void)
+{
+	int res = 0;
+	res |= ast_format_def_unregister(speex_f.name);
+	res |= ast_format_def_unregister(speex16_f.name);
+	res |= ast_format_def_unregister(speex32_f.name);
+	return res;
+}
+
 static int load_module(void)
 {
 	speex_f.format = ast_format_speex;
@@ -323,19 +332,11 @@
 	if (ast_format_def_register(&speex_f) ||
 	    ast_format_def_register(&speex16_f) ||
 	    ast_format_def_register(&speex32_f)) {
-		return AST_MODULE_LOAD_FAILURE;
+		unload_module();
+		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	return AST_MODULE_LOAD_SUCCESS;
-}
-
-static int unload_module(void)
-{
-	int res = 0;
-	res |= ast_format_def_unregister(speex_f.name);
-	res |= ast_format_def_unregister(speex16_f.name);
-	res |= ast_format_def_unregister(speex32_f.name);
-	return res;
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "OGG/Speex audio",
diff --git a/res/res_ari_events.c b/res/res_ari_events.c
index 065c8b7..ace23fe 100644
--- a/res/res_ari_events.c
+++ b/res/res_ari_events.c
@@ -425,11 +425,12 @@
 	struct ast_websocket_protocol *protocol;
 
 	if (ast_ari_websocket_events_event_websocket_init() == -1) {
-		return AST_MODULE_LOAD_FAILURE;
+		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	events.ws_server = ast_websocket_server_create();
 	if (!events.ws_server) {
+		ast_ari_websocket_events_event_websocket_dtor();
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
@@ -437,6 +438,7 @@
 	if (!protocol) {
 		ao2_ref(events.ws_server, -1);
 		events.ws_server = NULL;
+		ast_ari_websocket_events_event_websocket_dtor();
 		return AST_MODULE_LOAD_DECLINE;
 	}
 	protocol->session_attempted = ast_ari_events_event_websocket_ws_attempted_cb;
diff --git a/res/res_http_media_cache.c b/res/res_http_media_cache.c
index 2207b96..991abfb 100644
--- a/res/res_http_media_cache.c
+++ b/res/res_http_media_cache.c
@@ -427,13 +427,13 @@
 	if (ast_bucket_scheme_register("http", &http_bucket_wizard, &http_bucket_file_wizard,
 			NULL, NULL)) {
 		ast_log(LOG_ERROR, "Failed to register Bucket HTTP wizard scheme implementation\n");
-		return AST_MODULE_LOAD_FAILURE;
+		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	if (ast_bucket_scheme_register("https", &https_bucket_wizard, &https_bucket_file_wizard,
 			NULL, NULL)) {
 		ast_log(LOG_ERROR, "Failed to register Bucket HTTPS wizard scheme implementation\n");
-		return AST_MODULE_LOAD_FAILURE;
+		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	return AST_MODULE_LOAD_SUCCESS;
diff --git a/rest-api-templates/res_ari_resource.c.mustache b/rest-api-templates/res_ari_resource.c.mustache
index fcdc81a..903f7ad 100644
--- a/rest-api-templates/res_ari_resource.c.mustache
+++ b/rest-api-templates/res_ari_resource.c.mustache
@@ -267,11 +267,12 @@
 	struct ast_websocket_protocol *protocol;
 
 	if (ast_ari_websocket_{{c_name}}_{{c_nickname}}_init() == -1) {
-		return AST_MODULE_LOAD_FAILURE;
+		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	{{full_name}}.ws_server = ast_websocket_server_create();
 	if (!{{full_name}}.ws_server) {
+		ast_ari_websocket_events_event_websocket_dtor();
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
@@ -279,6 +280,7 @@
 	if (!protocol) {
 		ao2_ref({{full_name}}.ws_server, -1);
 		{{full_name}}.ws_server = NULL;
+		ast_ari_websocket_events_event_websocket_dtor();
 		return AST_MODULE_LOAD_DECLINE;
 	}
 	protocol->session_attempted = ast_ari_{{c_name}}_{{c_nickname}}_ws_attempted_cb;
diff --git a/tests/test_media_cache.c b/tests/test_media_cache.c
index 685693c..ca1e2dd 100644
--- a/tests/test_media_cache.c
+++ b/tests/test_media_cache.c
@@ -399,7 +399,7 @@
 	if (ast_bucket_scheme_register("httptest", &bucket_test_wizard,
 		&bucket_file_test_wizard, NULL, NULL)) {
 		ast_log(LOG_ERROR, "Failed to register Bucket HTTP test wizard scheme implementation\n");
-		return AST_MODULE_LOAD_FAILURE;
+		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	AST_TEST_REGISTER(exists_nominal);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If99e3b4fc2d7e86fc3e61182aa6c835b407ed49e
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: George Joseph <gjoseph at digium.com>



More information about the asterisk-code-review mailing list