main/formats: Fix crash in ast_format_cmp during non-clean shutdown.

* Backport ast_register_cleanup from Asterisk 12.
* Use ast_register_cleanup for format_attr_shutdown.

ast_register_cleanup was originally commited in r390122 by dlee.

(closes issue ASTERISK-23103)
Reported by: JoshE


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@411310 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Corey Farrell
2014-03-27 18:18:23 +00:00
parent 818f476893
commit 90fa4e3c36
3 changed files with 35 additions and 6 deletions

View File

@@ -89,6 +89,22 @@ int ast_pbx_init(void); /*!< Provided by pbx.c */
*/
int ast_register_atexit(void (*func)(void));
/*!
* \since 11.9
* \brief Register a function to be executed before Asterisk gracefully exits.
*
* If Asterisk is immediately shutdown (core stop now, or sending the TERM
* signal), the callback is not run. When the callbacks are run, they are run in
* sequence with ast_register_atexit() callbacks, in the reverse order of
* registration.
*
* \param func The callback function to use.
*
* \retval 0 on success.
* \retval -1 on error.
*/
int ast_register_cleanup(void (*func)(void));
/*!
* \brief Unregister a function registered with ast_register_atexit().
* \param func The callback function to unregister.