summaryrefslogtreecommitdiff
path: root/main/rtp_engine.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2017-12-29 19:24:02 -0500
committerCorey Farrell <git@cfware.com>2018-01-03 17:23:36 -0500
commit55f1d69c43d2c6c87eec50fd3eed7a77ba2e912b (patch)
tree0749060ca9d29dc796152f1654a340f091f4f600 /main/rtp_engine.c
parent7f4facc5e4a96ccae10283da998044becc4fbe11 (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 'main/rtp_engine.c')
-rw-r--r--main/rtp_engine.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 76bdf87b0..1c734778f 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -428,6 +428,7 @@ struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name,
struct ast_sockaddr address = {{0,}};
struct ast_rtp_instance *instance = NULL;
struct ast_rtp_engine *engine = NULL;
+ struct ast_module *mod_ref;
AST_RWLIST_RDLOCK(&engines);
@@ -450,10 +451,15 @@ struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name,
}
/* Bump up the reference count before we return so the module can not be unloaded */
- ast_module_ref(engine->mod);
+ mod_ref = ast_module_running_ref(engine->mod);
AST_RWLIST_UNLOCK(&engines);
+ if (!mod_ref) {
+ /* BUGBUG: improve handling of this situation. */
+ return NULL;
+ }
+
/* Allocate a new RTP instance */
if (!(instance = ao2_alloc(sizeof(*instance), instance_destructor))) {
ast_module_unref(engine->mod);