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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">sounds_index: Avoid repeatedly reindexing.<br><br>The sounds index is rebuilt each time a format is registered or<br>unregistered.  This causes the index to be repeatedly rebuilt during<br>startup and shutdown.<br><br>This patch significantly reduces the work done by delaying sound index<br>initialization until after modules are loaded.  This way a reindex only<br>occurs if a format module is loaded after startup.  We also skip<br>reindexing when format modules are unloaded during shutdown.<br><br>Change-Id: I585fd6ee04200612ab1490dc804f76805f89cf0a<br>---<br>M main/asterisk.c<br>M main/sounds_index.c<br>2 files changed, 11 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/asterisk.c b/main/asterisk.c<br>index 0abb360..3807b0a 100644<br>--- a/main/asterisk.c<br>+++ b/main/asterisk.c<br>@@ -4701,9 +4701,14 @@<br>    check_init(init_manager(), "Asterisk Manager Interface");<br>   check_init(ast_enum_init(), "ENUM Support");<br>        check_init(ast_cc_init(), "Call Completion Supplementary Services");<br>-       check_init(ast_sounds_index_init(), "Sounds Indexer");<br>      check_init(load_modules(0), "Module");<br> <br>+  /*<br>+    * This is initialized after the dynamic modules load to avoid repeatedly<br>+     * reindexing sounds for every format module load.<br>+    */<br>+  check_init(ast_sounds_index_init(), "Sounds Indexer");<br>+<br>   /* loads the cli_permissoins.conf file needed to implement cli restrictions. */<br>       ast_cli_perms_init(0);<br> <br>diff --git a/main/sounds_index.c b/main/sounds_index.c<br>index c7f9f4d..c792c1b 100644<br>--- a/main/sounds_index.c<br>+++ b/main/sounds_index.c<br>@@ -285,13 +285,15 @@<br> static void format_update_cb(void *data, struct stasis_subscription *sub,<br>     struct stasis_message *message)<br> {<br>-  ast_sounds_reindex();<br>+        /* Reindexing during shutdown is pointless. */<br>+       if (!ast_shutting_down()) {<br>+          ast_sounds_reindex();<br>+        }<br> }<br> <br> int ast_sounds_index_init(void)<br> {<br>        int res = 0;<br>- sounds_index = NULL;<br>  if (ast_sounds_reindex()) {<br>           return -1;<br>    }<br>@@ -328,6 +330,5 @@<br> <br> struct ast_media_index *ast_sounds_get_index(void)<br> {<br>-   ao2_ref(sounds_index, +1);<br>-   return sounds_index;<br>+ return ao2_bump(sounds_index);<br> }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7465">change 7465</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/7465"/><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: I585fd6ee04200612ab1490dc804f76805f89cf0a </div>
<div style="display:none"> Gerrit-Change-Number: 7465 </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: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>