<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7985">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Jenkins2: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">loader: Miscellaneous fixes.<br><br>* Remove comment about lazy load.<br>* Improve message about module already being loaded and running.<br>* Handle allocation error in add_to_load_order.<br>* Dead code elimination from modules_shutdown.<br><br>Change-Id: I22261599c46d0f416e568910ec9502f45143197f<br>---<br>M main/loader.c<br>1 file changed, 12 insertions(+), 16 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/loader.c b/main/loader.c<br>index b9baf3e..6119d63 100644<br>--- a/main/loader.c<br>+++ b/main/loader.c<br>@@ -530,9 +530,6 @@<br>          * If somehow there was another dlopen() on the same module (unlikely,<br>         * since that all is supposed to happen in loader.c).<br>          *<br>-    * Or the lazy resolution of a global symbol (very likely, since that is<br>-      * how we load all of our modules that export global symbols).<br>-        *<br>     * Avoid the temptation of repeating the dlclose(). The other code that<br>        * dlopened the module still has its module reference, and should close<br>        * it itself. In other situations, dlclose() will happily return success<br>@@ -637,7 +634,8 @@<br> int modules_shutdown(void)<br> {<br>        struct ast_module *mod;<br>-      int somethingchanged = 1, final = 0;<br>+ int somethingchanged;<br>+        int res;<br> <br>   AST_DLLIST_LOCK(&module_list);<br> <br>@@ -645,17 +643,11 @@<br>   * may be still in use, even if all channels are dead.  We must therefore<br>      * check the usecount before asking modules to unload. */<br>     do {<br>-         if (!somethingchanged) {<br>-                     /*!\note If we go through the entire list without changing<br>-                    * anything, ignore the usecounts and unload, then exit. */<br>-                  final = 1;<br>-           }<br>-<br>          /* Reset flag before traversing the list */<br>           somethingchanged = 0;<br> <br>              AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN(&module_list, mod, entry) {<br>-                     if (!final && mod->usecount) {<br>+                    if (mod->usecount) {<br>                               ast_debug(1, "Passing on %s: its use count is %d\n",<br>                                        mod->resource, mod->usecount);<br>                          continue;<br>@@ -678,12 +670,12 @@<br>                              }<br>                     }<br>             }<br>-    } while (somethingchanged && !final);<br>+        } while (somethingchanged);<br> <br>-       final = AST_DLLIST_EMPTY(&module_list);<br>+  res = AST_DLLIST_EMPTY(&module_list);<br>     AST_DLLIST_UNLOCK(&module_list);<br> <br>-      return !final;<br>+       return !res;<br> }<br> <br> int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode force)<br>@@ -1175,7 +1167,7 @@<br> <br>         if ((mod = find_resource(resource_name, 0))) {<br>                if (mod->flags.running) {<br>-                 ast_log(LOG_WARNING, "Module '%s' already exists.\n", resource_name);<br>+                      ast_log(LOG_WARNING, "Module '%s' already loaded and running.\n", resource_name);<br>                   return AST_MODULE_LOAD_DECLINE;<br>               }<br>             if (global_symbols_only && !ast_test_flag(mod->info, AST_MODFLAG_GLOBAL_SYMBOLS))<br>@@ -1255,6 +1247,11 @@<br>          return NULL;<br> <br>       order->resource = ast_strdup(resource);<br>+   if (!order->resource) {<br>+           ast_free(order);<br>+<br>+          return NULL;<br>+ }<br>     order->required = required;<br>        AST_LIST_INSERT_TAIL(load_order, order, entry);<br> <br>@@ -1437,7 +1434,6 @@<br>                     add_to_load_order(v->value, &load_order, 1);<br>                   ast_debug(2, "Adding module to required list: %s (%s)\n", v->value, v->name);<br>                 }<br>-<br>  }<br> <br>  /* check if 'autoload' is on */<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7985">change 7985</a>. To unsubscribe, 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/7985"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I22261599c46d0f416e568910ec9502f45143197f </div>
<div style="display:none"> Gerrit-Change-Number: 7985 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </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: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>