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/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@431662 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Corey Farrell
2015-02-11 15:38:39 +00:00
parent bc1e13dfc3
commit 9d5c52f10b
3 changed files with 105 additions and 6 deletions

View File

@@ -248,6 +248,10 @@ static int feature_hangup(struct ast_bridge *bridge, struct ast_bridge_channel *
static int unload_module(void)
{
ast_bridge_features_unregister(AST_BRIDGE_BUILTIN_HANGUP);
ast_bridge_features_unregister(AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER);
ast_bridge_features_unregister(AST_BRIDGE_BUILTIN_BLINDTRANSFER);
return 0;
}
@@ -257,8 +261,8 @@ static int load_module(void)
ast_bridge_features_register(AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER, feature_attended_transfer, NULL);
ast_bridge_features_register(AST_BRIDGE_BUILTIN_HANGUP, feature_hangup, NULL);
/* Bump up our reference count so we can't be unloaded */
ast_module_ref(ast_module_info->self);
/* This module cannot be unloaded until shutdown */
ast_module_shutdown_ref(ast_module_info->self);
return AST_MODULE_LOAD_SUCCESS;
}