[svn-commits] rmudgett: trunk r393489 - /trunk/apps/app_mixmonitor.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jul 2 15:56:15 CDT 2013


Author: rmudgett
Date: Tue Jul  2 15:56:13 2013
New Revision: 393489

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393489
Log:
MixMonitor: Remove some unnecessary channel locking.

Modified:
    trunk/apps/app_mixmonitor.c

Modified: trunk/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_mixmonitor.c?view=diff&rev=393489&r1=393488&r2=393489
==============================================================================
--- trunk/apps/app_mixmonitor.c (original)
+++ trunk/apps/app_mixmonitor.c Tue Jul  2 15:56:13 2013
@@ -810,7 +810,9 @@
 				*p2 = '$';
 			}
 		}
+		ast_channel_lock(chan);
 		pbx_substitute_variables_helper(chan, p1, postprocess2, sizeof(postprocess2) - 1);
+		ast_channel_unlock(chan);
 	}
 
 	/* Pre-allocate mixmonitor structure and spy */
@@ -1144,17 +1146,14 @@
 		return CLI_SUCCESS;
 	}
 
-	ast_channel_lock(chan);
-
 	if (!strcasecmp(a->argv[1], "start")) {
 		mixmonitor_exec(chan, (a->argc >= 4) ? a->argv[3] : "");
-		ast_channel_unlock(chan);
 	} else if (!strcasecmp(a->argv[1], "stop")){
-		ast_channel_unlock(chan);
 		stop_mixmonitor_exec(chan, (a->argc >= 4) ? a->argv[3] : "");
 	} else if (!strcasecmp(a->argv[1], "list")) {
 		ast_cli(a->fd, "MixMonitor ID\tFile\tReceive File\tTransmit File\n");
 		ast_cli(a->fd, "=========================================================================\n");
+		ast_channel_lock(chan);
 		AST_LIST_TRAVERSE(ast_channel_datastores(chan), datastore, entry) {
 			if (datastore->info == &mixmonitor_ds_info) {
 				char *filename = "";
@@ -1172,7 +1171,6 @@
 		}
 		ast_channel_unlock(chan);
 	} else {
-		ast_channel_unlock(chan);
 		chan = ast_channel_unref(chan);
 		return CLI_SHOWUSAGE;
 	}
@@ -1254,7 +1252,6 @@
 	char *opts[OPT_ARG_ARRAY_SIZE] = { NULL, };
 	struct ast_flags flags = { 0 };
 	char args[PATH_MAX] = "";
-	int res;
 
 	if (!ast_strlen_zero(options)) {
 		ast_app_parse_options(mixmonitor_opts, &flags, opts, ast_strdupa(options));
@@ -1262,11 +1259,7 @@
 
 	snprintf(args, sizeof(args), "%s,%s", filename, options);
 
-	ast_channel_lock(chan);
-	res = mixmonitor_exec(chan, args);
-	ast_channel_unlock(chan);
-
-	return res;
+	return mixmonitor_exec(chan, args);
 }
 
 static int stop_mixmonitor_callback(struct ast_channel *chan, const char *mixmonitor_id)
@@ -1307,14 +1300,15 @@
 
 	snprintf(args, sizeof(args), "%s,%s", file, options);
 
-	ast_channel_lock(c);
 	res = mixmonitor_exec(c, args);
 
 	if (ast_test_flag(&flags, MUXFLAG_UID)) {
 		uid_channel_var = opts[OPT_ARG_UID];
+		ast_channel_lock(c);
 		mixmonitor_id = pbx_builtin_getvar_helper(c, uid_channel_var);
-	}
-	ast_channel_unlock(c);
+		mixmonitor_id = ast_strdupa(S_OR(mixmonitor_id, ""));
+		ast_channel_unlock(c);
+	}
 
 	if (res) {
 		c = ast_channel_unref(c);




More information about the svn-commits mailing list