[asterisk-commits] loader: Flag module as declined in all cases where it fails ... (asterisk[16])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 10 14:22:14 CDT 2018


Kevin Harwell has submitted this change and it was merged. ( https://gerrit.asterisk.org/10442 )

Change subject: loader: Flag module as declined in all cases where it fails to load.
......................................................................

loader: Flag module as declined in all cases where it fails to load.

This has no effect on startup since AST_MODULE_LOAD_FAILURE aborts
startup, but it's possible for this code to be returned on manual load
of a module after startup.

It is an error for a module to not have a load callback but this is not
a fatal system error.  In this case flag the module as declined, return
AST_MODULE_LOAD_FAILURE only if a required module is broken.

Expand doxygen documentation for AST_MODULE_LOAD_*.

Change-Id: I3c030bb917f6e5a0dfd9d91491a4661b348cabf8
---
M include/asterisk/module.h
M main/loader.c
2 files changed, 39 insertions(+), 6 deletions(-)

Approvals:
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved; Approved for Submit



diff --git a/include/asterisk/module.h b/include/asterisk/module.h
index 08b4c43..2720d0e 100644
--- a/include/asterisk/module.h
+++ b/include/asterisk/module.h
@@ -66,11 +66,40 @@
 };
 
 enum ast_module_load_result {
-	AST_MODULE_LOAD_SUCCESS = 0,    /*!< Module loaded and configured */
-	AST_MODULE_LOAD_DECLINE = 1,    /*!< Module is not configured */
-	AST_MODULE_LOAD_SKIP = 2,       /*!< Module was skipped for some reason (For loader.c use only. Should never be returned by modules)*/
-	AST_MODULE_LOAD_PRIORITY = 3,   /*!< Module is not loaded yet, but is added to priority list */
-	AST_MODULE_LOAD_FAILURE = -1,   /*!< Module could not be loaded properly */
+	/*! Module is loaded and configured. */
+	AST_MODULE_LOAD_SUCCESS = 0,
+	/*!
+	 * \brief Module has failed to load, may be in an inconsistent state.
+	 *
+	 * This value is used when a module fails to start but does not risk
+	 * system-wide stability.  Declined modules will prevent any other
+	 * dependent module from starting.
+	 */
+	AST_MODULE_LOAD_DECLINE = 1,
+	/*! \internal
+	 * \brief Module was skipped for some reason.
+	 *
+	 * \note For loader.c use only. Should never be returned by modules.
+	 */
+	AST_MODULE_LOAD_SKIP = 2,
+	/*! \internal
+	 * \brief Module is not loaded yet, but is added to priority list.
+	 *
+	 * \note For loader.c use only. Should never be returned by modules.
+	 */
+	AST_MODULE_LOAD_PRIORITY = 3,
+	/*!
+	 * \brief Module could not be loaded properly.
+	 *
+	 * This return should only be returned by modules for unrecoverable
+	 * failures that cause the whole system to become unstable.  In almost
+	 * all cases \ref AST_MODULE_LOAD_DECLINE should be used instead.
+	 *
+	 * \warning Returning this code from any module will cause startup to abort.
+	 * If startup is already completed this code has the same effect as
+	 * \ref AST_MODULE_LOAD_DECLINE.
+	 */
+	AST_MODULE_LOAD_FAILURE = -1,
 };
 
 /*!
diff --git a/main/loader.c b/main/loader.c
index 865346f..3749c95 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -1545,7 +1545,9 @@
 	}
 
 	if (!mod->info->load) {
-		return AST_MODULE_LOAD_FAILURE;
+		mod->flags.declined = 1;
+
+		return mod->flags.required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE;
 	}
 
 	if (module_deps_reference(mod, NULL)) {
@@ -1593,6 +1595,8 @@
 		}
 		break;
 	case AST_MODULE_LOAD_FAILURE:
+		mod->flags.declined = 1;
+		break;
 	case AST_MODULE_LOAD_SKIP: /* modules should never return this value */
 	case AST_MODULE_LOAD_PRIORITY:
 		break;

-- 
To view, visit https://gerrit.asterisk.org/10442
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-MessageType: merged
Gerrit-Change-Id: I3c030bb917f6e5a0dfd9d91491a4661b348cabf8
Gerrit-Change-Number: 10442
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20181010/dd560ab1/attachment-0001.html>


More information about the asterisk-commits mailing list