diff options
author | Jenkins2 <jenkins2@gerrit.asterisk.org> | 2017-12-07 12:31:05 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-12-07 12:31:05 -0600 |
commit | a51c82eb025e3a82d95dd66cd4f87890148df1eb (patch) | |
tree | 96b292dc19d7292b0c46a355ff03c37ba9923001 | |
parent | c37093f2ff5b86ad510d92e49e0c82c613cabe4f (diff) | |
parent | c35613d2578c0ba14f84c7aa2eea64d2941b21a7 (diff) |
Merge "sounds_index: Avoid repeatedly reindexing." into 15
-rw-r--r-- | main/asterisk.c | 7 | ||||
-rw-r--r-- | main/sounds_index.c | 9 |
2 files changed, 11 insertions, 5 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index 2c86d1ebc..2238d433c 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -4632,10 +4632,15 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou 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"); + + /* * This has to load after the dynamic modules load, as items in the media * cache can't be constructed from items in the AstDB without their * bucket backends. diff --git a/main/sounds_index.c b/main/sounds_index.c index c7f9f4dd9..c792c1bbd 100644 --- a/main/sounds_index.c +++ b/main/sounds_index.c @@ -285,13 +285,15 @@ static void sounds_cleanup(void) 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 @@ int ast_sounds_index_init(void) struct ast_media_index *ast_sounds_get_index(void) { - ao2_ref(sounds_index, +1); - return sounds_index; + return ao2_bump(sounds_index); } |