diff options
author | Joshua Colp <jcolp@digium.com> | 2018-01-04 07:12:43 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2018-01-04 07:12:43 -0600 |
commit | 2fac32a37adbe92922212e17f2989cf1b0333832 (patch) | |
tree | bc99fa2c3a60f19f0684ae1a89eae82e611f22c6 /res | |
parent | 25399f74aab21c47d12e5abda4df0998787d16fe (diff) | |
parent | 55f1d69c43d2c6c87eec50fd3eed7a77ba2e912b (diff) |
Merge "loader: Create ast_module_running_ref."
Diffstat (limited to 'res')
-rw-r--r-- | res/res_agi.c | 29 | ||||
-rw-r--r-- | res/res_fax.c | 8 |
2 files changed, 20 insertions, 17 deletions
diff --git a/res/res_agi.c b/res/res_agi.c index 85914c018..393a50351 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -4040,14 +4040,19 @@ static enum agi_result agi_handle_command(struct ast_channel *chan, AGI *agi, ch parse_args(buf, &argc, argv); c = find_command(argv, 0); - if (c && (!dead || (dead && c->dead))) { - /* if this command wasn't registered by res_agi, be sure to usecount - the module we are using */ - if (c->mod != ast_module_info->self) - ast_module_ref(c->mod); + if (!c || !ast_module_running_ref(c->mod)) { + ami_res = "Invalid or unknown command"; + resultcode = 510; + + ast_agi_send(agi->fd, chan, "%d %s\n", resultcode, ami_res); + + publish_async_exec_end(chan, command_id, ami_cmd, resultcode, ami_res); + + return AGI_RESULT_SUCCESS; + } + + if (!dead || (dead && c->dead)) { res = c->handler(chan, agi, argc, argv); - if (c->mod != ast_module_info->self) - ast_module_unref(c->mod); switch (res) { case RESULT_SHOWUSAGE: ami_res = "Usage"; @@ -4094,21 +4099,15 @@ static enum agi_result agi_handle_command(struct ast_channel *chan, AGI *agi, ch break; } - } else if (c) { + } else { ami_res = "Command Not Permitted on a dead channel or intercept routine"; resultcode = 511; ast_agi_send(agi->fd, chan, "%d %s\n", resultcode, ami_res); publish_async_exec_end(chan, command_id, ami_cmd, resultcode, ami_res); - } else { - ami_res = "Invalid or unknown command"; - resultcode = 510; - - ast_agi_send(agi->fd, chan, "%d %s\n", resultcode, ami_res); - - publish_async_exec_end(chan, command_id, ami_cmd, resultcode, ami_res); } + ast_module_unref(c->mod); return AGI_RESULT_SUCCESS; } diff --git a/res/res_fax.c b/res/res_fax.c index 093845246..4be5aee75 100644 --- a/res/res_fax.c +++ b/res/res_fax.c @@ -1161,8 +1161,10 @@ static struct ast_fax_session *fax_session_reserve(struct ast_fax_session_detail if ((faxmod->tech->caps & details->caps) != details->caps) { continue; } + if (!ast_module_running_ref(faxmod->tech->module)) { + continue; + } ast_debug(4, "Reserving a FAX session from '%s'.\n", faxmod->tech->description); - ast_module_ref(faxmod->tech->module); s->tech = faxmod->tech; break; } @@ -1279,8 +1281,10 @@ static struct ast_fax_session *fax_session_new(struct ast_fax_session_details *d if ((faxmod->tech->caps & details->caps) != details->caps) { continue; } + if (!ast_module_running_ref(faxmod->tech->module)) { + continue; + } ast_debug(4, "Requesting a new FAX session from '%s'.\n", faxmod->tech->description); - ast_module_ref(faxmod->tech->module); if (reserved) { /* Balance module ref from reserved session */ ast_module_unref(reserved->tech->module); |