Enable REF_DEBUG for ast_module_ref / ast_module_unref.

Add ast_module_shutdown_ref for use by modules that can
only be unloaded during graceful shutdown.

When REF_DEBUG is enabled:
* Add an empty ao2 object to struct ast_module.
* Allocate ao2 object when the module is loaded.
* Perform an ao2_ref in each place where mod->usecount is manipulated.
* ao2_cleanup on module unload.

ASTERISK-24479 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4141/
........

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

Merged revisions 431663 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Corey Farrell
2015-02-11 17:03:04 +00:00
parent 137c4b0778
commit 8cc50b1ebc
3 changed files with 85 additions and 6 deletions

View File

@@ -316,8 +316,31 @@ void __ast_module_user_hangup_all(struct ast_module *);
#define ast_module_user_remove(user) __ast_module_user_remove(ast_module_info->self, user)
#define ast_module_user_hangup_all() __ast_module_user_hangup_all(ast_module_info->self)
struct ast_module *ast_module_ref(struct ast_module *);
void ast_module_unref(struct ast_module *);
struct ast_module *__ast_module_ref(struct ast_module *mod, const char *file, int line, const char *func);
void __ast_module_shutdown_ref(struct ast_module *mod, const char *file, int line, const char *func);
void __ast_module_unref(struct ast_module *mod, const char *file, int line, const char *func);
/*!
* \brief Hold a reference to the module
* \param mod Module to reference
* \return mod
*
* \note A module reference will prevent the module
* from being unloaded.
*/
#define ast_module_ref(mod) __ast_module_ref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief Prevent unload of the module before shutdown
* \param mod Module to hold
*
* \note This should not be balanced by a call to ast_module_unref.
*/
#define ast_module_shutdown_ref(mod) __ast_module_shutdown_ref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief Release a reference to the module
* \param mod Module to release
*/
#define ast_module_unref(mod) __ast_module_unref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#if defined(__cplusplus) || defined(c_plusplus)
#define AST_MODULE_INFO(keystr, flags_to_set, desc, load_func, unload_func, reload_func, load_pri, support_level) \