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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pbx_config.c: Fix reloading module if initially declined to load<br><br>Added decline if extensions.conf file not available<br>when loading pbx_config, and also made sure everything<br>gets properly unregistered and/or destroyed on unload.<br><br>Change-Id: Ib00665106043b1be5148ffa7a477396038915854<br>---<br>M pbx/pbx_config.c<br>1 file changed, 18 insertions(+), 9 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c</span><br><span>index 9577d2d..b1d5d53 100644</span><br><span>--- a/pbx/pbx_config.c</span><br><span>+++ b/pbx/pbx_config.c</span><br><span>@@ -1625,15 +1625,15 @@</span><br><span>  */</span><br><span> static int unload_module(void)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-        if (static_config && !write_protect_config)</span><br><span style="color: hsl(0, 100%, 40%);">-             ast_cli_unregister(&cli_dialplan_save);</span><br><span style="color: hsl(0, 100%, 40%);">-     if (overrideswitch_config) {</span><br><span style="color: hsl(0, 100%, 40%);">-            ast_free(overrideswitch_config);</span><br><span style="color: hsl(0, 100%, 40%);">-        }</span><br><span style="color: hsl(120, 100%, 40%);">+     ast_cli_unregister(&cli_dialplan_save);</span><br><span style="color: hsl(120, 100%, 40%);">+   ast_free(overrideswitch_config);</span><br><span style="color: hsl(120, 100%, 40%);">+      overrideswitch_config = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>      ast_cli_unregister_multiple(cli_pbx_config, ARRAY_LEN(cli_pbx_config));</span><br><span>      ast_manager_unregister(AMI_EXTENSION_ADD);</span><br><span>   ast_manager_unregister(AMI_EXTENSION_REMOVE);</span><br><span>        ast_context_destroy(NULL, registrar);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>      return 0;</span><br><span> }</span><br><span> </span><br><span>@@ -2081,10 +2081,17 @@</span><br><span> </span><br><span>     ast_mutex_lock(&reload_lock);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   if (!local_table)</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!local_table) {</span><br><span>          local_table = ast_hashtab_create(17, ast_hashtab_compare_contexts, ast_hashtab_resize_java, ast_hashtab_newsize_java, ast_hashtab_hash_contexts, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+          if (!local_table) {</span><br><span style="color: hsl(120, 100%, 40%);">+                   ast_mutex_unlock(&reload_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+                   return AST_MODULE_LOAD_DECLINE;</span><br><span style="color: hsl(120, 100%, 40%);">+               }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span> </span><br><span>        if (!pbx_load_config(config)) {</span><br><span style="color: hsl(120, 100%, 40%);">+               ast_hashtab_destroy(local_table, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+               local_table = NULL;</span><br><span>          ast_mutex_unlock(&reload_lock);</span><br><span>          return AST_MODULE_LOAD_DECLINE;</span><br><span>      }</span><br><span>@@ -2111,6 +2118,11 @@</span><br><span> {</span><br><span>      int res;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+  if (pbx_load_module()) {</span><br><span style="color: hsl(120, 100%, 40%);">+              unload_module();</span><br><span style="color: hsl(120, 100%, 40%);">+              return AST_MODULE_LOAD_DECLINE;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  if (static_config && !write_protect_config)</span><br><span>          ast_cli_register(&cli_dialplan_save);</span><br><span>    ast_cli_register_multiple(cli_pbx_config, ARRAY_LEN(cli_pbx_config));</span><br><span>@@ -2125,9 +2137,6 @@</span><br><span>                return AST_MODULE_LOAD_DECLINE;</span><br><span>      }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   if (pbx_load_module())</span><br><span style="color: hsl(0, 100%, 40%);">-          return AST_MODULE_LOAD_DECLINE;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>      return AST_MODULE_LOAD_SUCCESS;</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9886">change 9886</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/9886"/><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: Ib00665106043b1be5148ffa7a477396038915854 </div>
<div style="display:none"> Gerrit-Change-Number: 9886 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Chris Savinovich <csavinovich@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>