diff options
author | Corey Farrell <git@cfware.com> | 2015-02-11 15:51:33 +0000 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2015-02-11 15:51:33 +0000 |
commit | 2531f750576542037e93f4c4e087f9dbced1897d (patch) | |
tree | 2a97bf142cabc28c23cf3257ecd45908004fe3f3 /include/asterisk/module.h | |
parent | 4d8ab20a8abac76c680a40605bb6e6e8e675afde (diff) |
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
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@431663 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/module.h')
-rw-r--r-- | include/asterisk/module.h | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/include/asterisk/module.h b/include/asterisk/module.h index d6e1d9039..6d5e04dfc 100644 --- a/include/asterisk/module.h +++ b/include/asterisk/module.h @@ -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) \ |