<p>Kevin Harwell <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10442">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Benjamin Keith Ford: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">loader: Flag module as declined in all cases where it fails to load.<br><br>This has no effect on startup since AST_MODULE_LOAD_FAILURE aborts<br>startup, but it's possible for this code to be returned on manual load<br>of a module after startup.<br><br>It is an error for a module to not have a load callback but this is not<br>a fatal system error. In this case flag the module as declined, return<br>AST_MODULE_LOAD_FAILURE only if a required module is broken.<br><br>Expand doxygen documentation for AST_MODULE_LOAD_*.<br><br>Change-Id: I3c030bb917f6e5a0dfd9d91491a4661b348cabf8<br>---<br>M include/asterisk/module.h<br>M main/loader.c<br>2 files changed, 39 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/asterisk/module.h b/include/asterisk/module.h</span><br><span>index 08b4c43..2720d0e 100644</span><br><span>--- a/include/asterisk/module.h</span><br><span>+++ b/include/asterisk/module.h</span><br><span>@@ -66,11 +66,40 @@</span><br><span> };</span><br><span> </span><br><span> enum ast_module_load_result {</span><br><span style="color: hsl(0, 100%, 40%);">- AST_MODULE_LOAD_SUCCESS = 0, /*!< Module loaded and configured */</span><br><span style="color: hsl(0, 100%, 40%);">- AST_MODULE_LOAD_DECLINE = 1, /*!< Module is not configured */</span><br><span style="color: hsl(0, 100%, 40%);">- AST_MODULE_LOAD_SKIP = 2, /*!< Module was skipped for some reason (For loader.c use only. Should never be returned by modules)*/</span><br><span style="color: hsl(0, 100%, 40%);">- AST_MODULE_LOAD_PRIORITY = 3, /*!< Module is not loaded yet, but is added to priority list */</span><br><span style="color: hsl(0, 100%, 40%);">- AST_MODULE_LOAD_FAILURE = -1, /*!< Module could not be loaded properly */</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! Module is loaded and configured. */</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_MODULE_LOAD_SUCCESS = 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ /*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Module has failed to load, may be in an inconsistent state.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This value is used when a module fails to start but does not risk</span><br><span style="color: hsl(120, 100%, 40%);">+ * system-wide stability. Declined modules will prevent any other</span><br><span style="color: hsl(120, 100%, 40%);">+ * dependent module from starting.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_MODULE_LOAD_DECLINE = 1,</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! \internal</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Module was skipped for some reason.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \note For loader.c use only. Should never be returned by modules.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_MODULE_LOAD_SKIP = 2,</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! \internal</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Module is not loaded yet, but is added to priority list.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \note For loader.c use only. Should never be returned by modules.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_MODULE_LOAD_PRIORITY = 3,</span><br><span style="color: hsl(120, 100%, 40%);">+ /*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Module could not be loaded properly.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This return should only be returned by modules for unrecoverable</span><br><span style="color: hsl(120, 100%, 40%);">+ * failures that cause the whole system to become unstable. In almost</span><br><span style="color: hsl(120, 100%, 40%);">+ * all cases \ref AST_MODULE_LOAD_DECLINE should be used instead.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \warning Returning this code from any module will cause startup to abort.</span><br><span style="color: hsl(120, 100%, 40%);">+ * If startup is already completed this code has the same effect as</span><br><span style="color: hsl(120, 100%, 40%);">+ * \ref AST_MODULE_LOAD_DECLINE.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_MODULE_LOAD_FAILURE = -1,</span><br><span> };</span><br><span> </span><br><span> /*!</span><br><span>diff --git a/main/loader.c b/main/loader.c</span><br><span>index 865346f..3749c95 100644</span><br><span>--- a/main/loader.c</span><br><span>+++ b/main/loader.c</span><br><span>@@ -1545,7 +1545,9 @@</span><br><span> }</span><br><span> </span><br><span> if (!mod->info->load) {</span><br><span style="color: hsl(0, 100%, 40%);">- return AST_MODULE_LOAD_FAILURE;</span><br><span style="color: hsl(120, 100%, 40%);">+ mod->flags.declined = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return mod->flags.required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE;</span><br><span> }</span><br><span> </span><br><span> if (module_deps_reference(mod, NULL)) {</span><br><span>@@ -1593,6 +1595,8 @@</span><br><span> }</span><br><span> break;</span><br><span> case AST_MODULE_LOAD_FAILURE:</span><br><span style="color: hsl(120, 100%, 40%);">+ mod->flags.declined = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span> case AST_MODULE_LOAD_SKIP: /* modules should never return this value */</span><br><span> case AST_MODULE_LOAD_PRIORITY:</span><br><span> break;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10442">change 10442</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10442"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I3c030bb917f6e5a0dfd9d91491a4661b348cabf8 </div>
<div style="display:none"> Gerrit-Change-Number: 10442 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>