[asterisk-commits] res/res corosync: Always decline module load, instead of fai... (asterisk[certified/13.1])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 30 07:35:25 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: res/res_corosync: Always decline module load, instead of failing
......................................................................


res/res_corosync: Always decline module load, instead of failing

Returns a 'failure' from the module load routine indicates to Asterisk
that it should abort loading completely. This is rarely - in fact,
really, never - a good option. Aborting load of Asterisk from a dynamic
module implies that the core, and the rest of the dynamic modules, don't
matter: we should abandon all processing.

res_corosync is really not that important.

This patch updates the module such that, if it fails to load, it
politely declines (emitting ERROR messages along the way), and allows
Asterisk to continue to function.

Note that this issue was keeping Asterisk unit tests from running on
certain build agents.

Change-Id: I252249e81fb9b1a68e0da873f54f47e21d648f0f
---
M res/res_corosync.c
1 file changed, 6 insertions(+), 8 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/res/res_corosync.c b/res/res_corosync.c
index 58290c7..72da3f1 100644
--- a/res/res_corosync.c
+++ b/res/res_corosync.c
@@ -863,7 +863,6 @@
 static int load_module(void)
 {
 	cs_error_t cs_err;
-	enum ast_module_load_result res = AST_MODULE_LOAD_FAILURE;
 	struct cpg_name name;
 
 	corosync_aggregate_topic = stasis_topic_create("corosync_aggregate_topic");
@@ -880,6 +879,11 @@
 
 	if (STASIS_MESSAGE_TYPE_INIT(corosync_ping_message_type) != 0) {
 		ast_log(AST_LOG_ERROR, "Failed to initialize corosync ping message type\n");
+		goto failed;
+	}
+
+	if (load_config(0)) {
+		/* simply not configured is not a fatal error */
 		goto failed;
 	}
 
@@ -913,12 +917,6 @@
 		goto failed;
 	}
 
-	if (load_config(0)) {
-		/* simply not configured is not a fatal error */
-		res = AST_MODULE_LOAD_DECLINE;
-		goto failed;
-	}
-
 	ast_cli_register_multiple(corosync_cli, ARRAY_LEN(corosync_cli));
 
 	return AST_MODULE_LOAD_SUCCESS;
@@ -926,7 +924,7 @@
 failed:
 	cleanup_module();
 
-	return res;
+	return AST_MODULE_LOAD_DECLINE;
 }
 
 static int unload_module(void)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I252249e81fb9b1a68e0da873f54f47e21d648f0f
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: certified/13.1
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list