Massive cleanups to applications for LOCAL_USER handling and some other things.

In general, LOCAL_USER_ADD/REMOVE should be the first/last thing called in an
application.  An exception is if there is some *fast* setup code that might
halt the execution of the application, such as checking to see if an argument
exists.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6832 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2005-10-19 18:19:02 +00:00
parent e5afdbbe16
commit 4aa7912057
74 changed files with 817 additions and 405 deletions

View File

@@ -382,34 +382,36 @@ static int muxmon_exec(struct ast_channel *chan, void *data)
*filename = NULL,
*post_process = NULL;
if (!data) {
if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "muxmon requires an argument\n");
return -1;
}
if (!(args = ast_strdupa(data))) {
LOCAL_USER_ADD(u);
args = ast_strdupa(data);
if (!args) {
ast_log(LOG_WARNING, "Memory Error!\n");
return -1;
LOCAL_USER_REMOVE(u);
return -1;
}
if ((argc = ast_separate_app_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
filename = argv[0];
if ( argc > 1) {
if (argc > 1) {
options = argv[1];
}
if ( argc > 2) {
if (argc > 2) {
post_process = argv[2];
}
}
if (!filename || ast_strlen_zero(filename)) {
ast_log(LOG_WARNING, "Muxmon requires an argument (filename)\n");
return -1;
LOCAL_USER_REMOVE(u);
return -1;
}
LOCAL_USER_ADD(u);
if (options) {
char *opts[3] = {};
ast_parseoptions(muxmon_opts, &flags, opts, options);
@@ -440,13 +442,13 @@ static int muxmon_exec(struct ast_channel *chan, void *data)
else {
readvol = writevol = minmax(x, 4);
x = get_volfactor(readvol);
readvol = minmax(x, 16);
readvol = minmax(x, 16);
x = get_volfactor(writevol);
writevol = minmax(x, 16);
writevol = minmax(x, 16);
}
}
}
pbx_builtin_setvar_helper(chan, "MUXMON_FILENAME", filename);
pbx_builtin_setvar_helper(chan, "MUXMON_FILENAME", filename);
launch_monitor_thread(chan, filename, flags.flags, readvol, writevol, post_process);
LOCAL_USER_REMOVE(u);