diff options
author | Corey Farrell <git@cfware.com> | 2017-12-29 19:24:02 -0500 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2018-01-03 17:23:36 -0500 |
commit | 55f1d69c43d2c6c87eec50fd3eed7a77ba2e912b (patch) | |
tree | 0749060ca9d29dc796152f1654a340f091f4f600 /include/asterisk | |
parent | 7f4facc5e4a96ccae10283da998044becc4fbe11 (diff) |
loader: Create ast_module_running_ref.
This function returns NULL if the module in question is not running. I
did not change ast_module_ref as most callers do not check the result
and they always call ast_module_unref.
Make use of this function when running registered items from:
* app_stack API's
* bridge technologies
* CLI commands
* File formats
* Manager Actions
* RTP engines
* Sorcery Wizards
* Timing Interfaces
* Translators
* AGI Commands
* Fax Technologies
ASTERISK-20346 #close
Change-Id: Ia16fd28e188b2fc0b9d18b8a5d9cacc31df73fcc
Diffstat (limited to 'include/asterisk')
-rw-r--r-- | include/asterisk/module.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/asterisk/module.h b/include/asterisk/module.h index d3b9ddc20..103cd3053 100644 --- a/include/asterisk/module.h +++ b/include/asterisk/module.h @@ -357,6 +357,7 @@ void __ast_module_user_hangup_all(struct ast_module *); #define ast_module_user_hangup_all() __ast_module_user_hangup_all(AST_MODULE_SELF) struct ast_module *__ast_module_ref(struct ast_module *mod, const char *file, int line, const char *func); +struct ast_module *__ast_module_running_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); @@ -369,6 +370,20 @@ void __ast_module_unref(struct ast_module *mod, const char *file, int line, cons * from being unloaded. */ #define ast_module_ref(mod) __ast_module_ref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__) + +/*! + * \brief Hold a reference to the module if it is running. + * \param mod Module to reference + * \retval mod if running + * \retval NULL if not running + * + * The returned pointer should be released with ast_module_unref. + * + * \note A module reference will prevent the module from being unloaded. + */ +#define ast_module_running_ref(mod) \ + __ast_module_running_ref(mod, __FILE__, __LINE__, __PRETTY_FUNCTION__) + /*! * \brief Prevent unload of the module before shutdown * \param mod Module to hold |