Replace most uses of ast_register_atexit with ast_register_cleanup.

Since 'core stop now' and 'core restart now' do not stop modules,
it is unsafe for most of the core to run cleanups.  Originally all
cleanups used ast_register_atexit, and were only changed when it
was shown to be unsafe.  ast_register_atexit is now used only when
absolutely required to prevent corruption and close child processes.

Exceptions that need to use ast_register_atexit:
* CDR: Flush records.
* res_musiconhold: Kill external applications.
* AstDB: Close the DB.
* canary_exit: Kill canary process.

ASTERISK-24142 #close
Reported by: David Brillert

ASTERISK-24683 #close
Reported by: Peter Katzmann

ASTERISK-24805 #close
Reported by: Badalian Vyacheslav

ASTERISK-24881 #close
Reported by: Corey Farrell

Review: https://reviewboard.asterisk.org/r/4500/
Review: https://reviewboard.asterisk.org/r/4501/
........

Merged revisions 433495 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433497 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Corey Farrell
2015-03-26 22:19:21 +00:00
parent d0df545a44
commit 6adf26f14d
45 changed files with 65 additions and 107 deletions

View File

@@ -416,16 +416,11 @@ static int object_type_field_cmp(void *obj, void *arg, int flags)
return CMP_MATCH;
}
/*! \brief Cleanup function */
static void sorcery_exit(void)
{
ast_threadpool_shutdown(threadpool);
threadpool = NULL;
}
/*! \brief Cleanup function for graceful shutdowns */
static void sorcery_cleanup(void)
{
ast_threadpool_shutdown(threadpool);
threadpool = NULL;
ao2_cleanup(wizards);
wizards = NULL;
ao2_cleanup(observers);
@@ -507,7 +502,6 @@ int ast_sorcery_init(void)
observers = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_RWLOCK, 0, NULL, NULL);
if (!observers) {
sorcery_cleanup();
sorcery_exit();
return -1;
}
@@ -515,12 +509,10 @@ int ast_sorcery_init(void)
sorcery_instance_hash, sorcery_instance_cmp);
if (!instances) {
sorcery_cleanup();
sorcery_exit();
return -1;
}
ast_register_cleanup(sorcery_cleanup);
ast_register_atexit(sorcery_exit);
return 0;
}