Skip to content
Snippets Groups Projects
Commit 40bc805b authored by Joshua Colp's avatar Joshua Colp Committed by Gerrit Code Review
Browse files

Merge "res_sorcery_memory_cache.c: Shutdown in a less crash potential order."

parents 8804ad62 6554a3b2
No related branches found
No related tags found
No related merge requests found
......@@ -2482,22 +2482,6 @@ cleanup:
static int unload_module(void)
{
if (sched) {
ast_sched_context_destroy(sched);
sched = NULL;
}
ao2_cleanup(caches);
ast_sorcery_wizard_unregister(&memory_cache_object_wizard);
ast_cli_unregister_multiple(cli_memory_cache, ARRAY_LEN(cli_memory_cache));
ast_manager_unregister("SorceryMemoryCacheExpireObject");
ast_manager_unregister("SorceryMemoryCacheExpire");
ast_manager_unregister("SorceryMemoryCacheStaleObject");
ast_manager_unregister("SorceryMemoryCacheStale");
AST_TEST_UNREGISTER(open_with_valid_options);
AST_TEST_UNREGISTER(open_with_invalid_options);
AST_TEST_UNREGISTER(create_and_retrieve);
......@@ -2507,6 +2491,27 @@ static int unload_module(void)
AST_TEST_UNREGISTER(expiration);
AST_TEST_UNREGISTER(stale);
ast_manager_unregister("SorceryMemoryCacheExpireObject");
ast_manager_unregister("SorceryMemoryCacheExpire");
ast_manager_unregister("SorceryMemoryCacheStaleObject");
ast_manager_unregister("SorceryMemoryCacheStale");
ast_cli_unregister_multiple(cli_memory_cache, ARRAY_LEN(cli_memory_cache));
ast_sorcery_wizard_unregister(&memory_cache_object_wizard);
/*
* XXX There is the potential to leak memory if there are pending
* next-cache-expiration and stale-cache-update tasks in the scheduler.
*/
if (sched) {
ast_sched_context_destroy(sched);
sched = NULL;
}
ao2_cleanup(caches);
caches = NULL;
return 0;
}
......@@ -2514,6 +2519,14 @@ static int load_module(void)
{
int res;
caches = ao2_container_alloc(CACHES_CONTAINER_BUCKET_SIZE, sorcery_memory_cache_hash,
sorcery_memory_cache_cmp);
if (!caches) {
ast_log(LOG_ERROR, "Failed to create container for configured caches\n");
unload_module();
return AST_MODULE_LOAD_DECLINE;
}
sched = ast_sched_context_create();
if (!sched) {
ast_log(LOG_ERROR, "Failed to create scheduler for cache management\n");
......@@ -2527,14 +2540,6 @@ static int load_module(void)
return AST_MODULE_LOAD_DECLINE;
}
caches = ao2_container_alloc(CACHES_CONTAINER_BUCKET_SIZE, sorcery_memory_cache_hash,
sorcery_memory_cache_cmp);
if (!caches) {
ast_log(LOG_ERROR, "Failed to create container for configured caches\n");
unload_module();
return AST_MODULE_LOAD_DECLINE;
}
if (ast_sorcery_wizard_register(&memory_cache_object_wizard)) {
unload_module();
return AST_MODULE_LOAD_DECLINE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment