diff options
author | Corey Farrell <git@cfware.com> | 2018-03-10 04:33:33 -0500 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2018-03-13 13:46:08 -0400 |
commit | fee929c8acd788a77982b537953bf4053242057e (patch) | |
tree | 423c7c705fc7f981ad50c08982da312ab30413ed /main/media_cache.c | |
parent | a979e52c0a351b6784530be04c0b096a7428a720 (diff) |
core: Remove non-critical cleanup from startup aborts.
When built-in components of Asterisk fail to start they cause the
Asterisk startup to abort. In these cases only the most critical
cleanup should be performed - closing databases and terminating
proceses. These cleanups are registered using ast_register_atexit, all
other cleanups should not be run during startup abort.
The main reason for this change is that these cleanup procedures are
untestable from the partially initialized states, if they fail it could
prevent us from ever running the critical cleanup with ast_run_atexits.
Create separate initialization for dns_core.c to be run unconditionally
during startup instead of being initialized by the first dns resolver to
be registered. This ensures that 'sched' is initialized before it can be
potentially used.
Replace ast_register_atexit with ast_register_cleanup in media_cache.c.
There is no reason for this cleanup to happen unconditionally.
Change-Id: Iecc2df98008b21509925ff16740bd5fa29527db3
Diffstat (limited to 'main/media_cache.c')
-rw-r--r-- | main/media_cache.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/main/media_cache.c b/main/media_cache.c index 90057dc6f..e93d1a02f 100644 --- a/main/media_cache.c +++ b/main/media_cache.c @@ -645,7 +645,7 @@ static struct ast_cli_entry cli_media_cache[] = { */ static void media_cache_shutdown(void) { - ao2_ref(media_cache, -1); + ao2_cleanup(media_cache); media_cache = NULL; ast_cli_unregister_multiple(cli_media_cache, ARRAY_LEN(cli_media_cache)); @@ -653,7 +653,7 @@ static void media_cache_shutdown(void) int ast_media_cache_init(void) { - ast_register_atexit(media_cache_shutdown); + ast_register_cleanup(media_cache_shutdown); media_cache = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_MUTEX, AO2_BUCKETS, ast_sorcery_object_id_hash, ast_sorcery_object_id_compare); @@ -662,7 +662,6 @@ int ast_media_cache_init(void) } if (ast_cli_register_multiple(cli_media_cache, ARRAY_LEN(cli_media_cache))) { - ao2_ref(media_cache, -1); return -1; } |