[asterisk-commits] qwell: branch qwell/ari_channel_variables r393329 - in /team/qwell/ari_channe...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 1 13:49:41 CDT 2013


Author: qwell
Date: Mon Jul  1 13:49:39 2013
New Revision: 393329

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393329
Log:
Address feedback.

Modified:
    team/qwell/ari_channel_variables/res/stasis/control.c
    team/qwell/ari_channel_variables/res/stasis_http/resource_asterisk.c
    team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c

Modified: team/qwell/ari_channel_variables/res/stasis/control.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/res/stasis/control.c?view=diff&rev=393329&r1=393328&r2=393329
==============================================================================
--- team/qwell/ari_channel_variables/res/stasis/control.c (original)
+++ team/qwell/ari_channel_variables/res/stasis/control.c Mon Jul  1 13:49:39 2013
@@ -137,11 +137,14 @@
 	char *value;
 
 	if (variable[strlen(variable) - 1] == ')') {
-		char workspace[1024];
-
-		ast_func_read(control->channel, (char *)variable, workspace, sizeof(workspace));
-
-		value = ast_strdup(workspace);
+		if (!(value = ast_malloc(1024))) {
+			return NULL;
+		}
+
+		if (ast_func_read(control->channel, variable, value, 1024)) {
+			ast_free(value);
+			return NULL;
+		}
 	} else {
 		value = ast_strdup(pbx_builtin_getvar_helper(control->channel, variable));
 	}
@@ -151,12 +154,7 @@
 
 int stasis_app_control_set_channel_var(struct stasis_app_control *control, const char *variable, const char *value)
 {
-	SCOPED_CHANNELLOCK(lockvar, control->channel);
-	int ret;
-
-	ret = pbx_builtin_setvar_helper(control->channel, variable, value);
-
-	return ret;
+	return pbx_builtin_setvar_helper(control->channel, variable, value);
 }
 
 struct ast_channel_snapshot *stasis_app_control_get_snapshot(

Modified: team/qwell/ari_channel_variables/res/stasis_http/resource_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/res/stasis_http/resource_asterisk.c?view=diff&rev=393329&r1=393328&r2=393329
==============================================================================
--- team/qwell/ari_channel_variables/res/stasis_http/resource_asterisk.c (original)
+++ team/qwell/ari_channel_variables/res/stasis_http/resource_asterisk.c Mon Jul  1 13:49:39 2013
@@ -60,12 +60,14 @@
 {
 	ast_assert(response != NULL);
 
-	if (pbx_builtin_setvar_helper(NULL, args->variable, args->value)) {
+	if (ast_strlen_zero(args->variable)) {
 		stasis_http_response_error(
-			response, 500, "Internal server error",
-			"Failed to set variable");
+			response, 400, "Bad Request",
+			"Variable name is required");
 		return;
 	}
 
+	pbx_builtin_setvar_helper(NULL, args->variable, args->value);
+
 	stasis_http_response_no_content(response);
 }

Modified: team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c?view=diff&rev=393329&r1=393328&r2=393329
==============================================================================
--- team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c (original)
+++ team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c Mon Jul  1 13:49:39 2013
@@ -431,10 +431,17 @@
 		return;
 	}
 
+	if (ast_strlen_zero(args->variable)) {
+		stasis_http_response_error(
+			response, 400, "Bad Request",
+			"Variable name is required");
+		return;
+	}
+
 	if (stasis_app_control_set_channel_var(control, args->variable, args->value)) {
 		stasis_http_response_error(
-			response, 500, "Internal server error",
-			"Failed to set variable");
+			response, 400, "Bad Request",
+			"Failed to execute function");
 		return;
 	}
 




More information about the asterisk-commits mailing list