<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7454">View Change</a></p><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 ignoring format<br>register / unregister during startup or shutdown.  The sounds index is<br>rebuilt once when asterisk is fully booted.  During shutdown we simply<br>destroy the index when appropriate.<br><br>Change-Id: I585fd6ee04200612ab1490dc804f76805f89cf0a<br>---<br>M main/sounds_index.c<br>1 file changed, 29 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/54/7454/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/sounds_index.c b/main/sounds_index.c<br>index c7f9f4d..2528d4b 100644<br>--- a/main/sounds_index.c<br>+++ b/main/sounds_index.c<br>@@ -285,6 +285,32 @@<br> static void format_update_cb(void *data, struct stasis_subscription *sub,<br>    struct stasis_message *message)<br> {<br>+  /* Instead of reindexing after each format module loads we defer until FullyBooted.<br>+   * During shutdown we just don't bother, leave it to sounds_cleanup. */<br>+  if (ast_fully_booted && !ast_shutting_down()) {<br>+              ast_sounds_reindex();<br>+        }<br>+}<br>+<br>+/*! \brief Event callback which fires sounds reindex when the system is fully booted */<br>+static void sounds_fullybooted_reindex(void *data, struct stasis_subscription *sub,<br>+     struct stasis_message *message)<br>+{<br>+  struct ast_json_payload *payload;<br>+    const char *type;<br>+<br>+ if (stasis_message_type(message) != ast_manager_get_generic_type()) {<br>+                return;<br>+      }<br>+<br>+ payload = stasis_message_data(message);<br>+      type = ast_json_string_get(ast_json_object_get(payload->json, "type"));<br>+<br>+      if (strcmp(type, "FullyBooted")) {<br>+         return;<br>+      }<br>+<br>+ stasis_unsubscribe(sub);<br>      ast_sounds_reindex();<br> }<br> <br>@@ -292,9 +318,12 @@<br> {<br>        int res = 0;<br>  sounds_index = NULL;<br>+<br>       if (ast_sounds_reindex()) {<br>           return -1;<br>    }<br>+    stasis_subscribe_pool(ast_manager_get_topic(), sounds_fullybooted_reindex, NULL);<br>+<br>  res |= ast_cli_register_multiple(cli_sounds, ARRAY_LEN(cli_sounds));<br> <br>       sounds_system_router = stasis_message_router_create(ast_system_topic());<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7454">change 7454</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/7454"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I585fd6ee04200612ab1490dc804f76805f89cf0a </div>
<div style="display:none"> Gerrit-Change-Number: 7454 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>