[Asterisk-code-review] sounds index: Avoid repeatedly reindexing. (asterisk[13])
Jenkins2
asteriskteam at digium.com
Thu Dec 7 12:43:45 CST 2017
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7465 )
Change subject: sounds_index: Avoid repeatedly reindexing.
......................................................................
sounds_index: Avoid repeatedly reindexing.
The sounds index is rebuilt each time a format is registered or
unregistered. This causes the index to be repeatedly rebuilt during
startup and shutdown.
This patch significantly reduces the work done by delaying sound index
initialization until after modules are loaded. This way a reindex only
occurs if a format module is loaded after startup. We also skip
reindexing when format modules are unloaded during shutdown.
Change-Id: I585fd6ee04200612ab1490dc804f76805f89cf0a
---
M main/asterisk.c
M main/sounds_index.c
2 files changed, 11 insertions(+), 5 deletions(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/main/asterisk.c b/main/asterisk.c
index 0abb360..3807b0a 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -4701,9 +4701,14 @@
check_init(init_manager(), "Asterisk Manager Interface");
check_init(ast_enum_init(), "ENUM Support");
check_init(ast_cc_init(), "Call Completion Supplementary Services");
- check_init(ast_sounds_index_init(), "Sounds Indexer");
check_init(load_modules(0), "Module");
+ /*
+ * This is initialized after the dynamic modules load to avoid repeatedly
+ * reindexing sounds for every format module load.
+ */
+ check_init(ast_sounds_index_init(), "Sounds Indexer");
+
/* loads the cli_permissoins.conf file needed to implement cli restrictions. */
ast_cli_perms_init(0);
diff --git a/main/sounds_index.c b/main/sounds_index.c
index c7f9f4d..c792c1b 100644
--- a/main/sounds_index.c
+++ b/main/sounds_index.c
@@ -285,13 +285,15 @@
static void format_update_cb(void *data, struct stasis_subscription *sub,
struct stasis_message *message)
{
- ast_sounds_reindex();
+ /* Reindexing during shutdown is pointless. */
+ if (!ast_shutting_down()) {
+ ast_sounds_reindex();
+ }
}
int ast_sounds_index_init(void)
{
int res = 0;
- sounds_index = NULL;
if (ast_sounds_reindex()) {
return -1;
}
@@ -328,6 +330,5 @@
struct ast_media_index *ast_sounds_get_index(void)
{
- ao2_ref(sounds_index, +1);
- return sounds_index;
+ return ao2_bump(sounds_index);
}
--
To view, visit https://gerrit.asterisk.org/7465
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I585fd6ee04200612ab1490dc804f76805f89cf0a
Gerrit-Change-Number: 7465
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171207/866f8143/attachment.html>
More information about the asterisk-code-review
mailing list