[asterisk-commits] dlee: branch dlee/allow-multiple r395449 - in /team/dlee/allow-multiple: res/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 25 14:45:35 CDT 2013


Author: dlee
Date: Thu Jul 25 14:45:34 2013
New Revision: 395449

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395449
Log:
Report allowMultiple failures

Modified:
    team/dlee/allow-multiple/res/res_stasis_http_asterisk.c
    team/dlee/allow-multiple/res/res_stasis_http_bridges.c
    team/dlee/allow-multiple/res/res_stasis_http_channels.c
    team/dlee/allow-multiple/res/res_stasis_http_endpoints.c
    team/dlee/allow-multiple/res/res_stasis_http_events.c
    team/dlee/allow-multiple/res/res_stasis_http_playback.c
    team/dlee/allow-multiple/res/res_stasis_http_recordings.c
    team/dlee/allow-multiple/res/res_stasis_http_sounds.c
    team/dlee/allow-multiple/rest-api-templates/param_cleanup.mustache
    team/dlee/allow-multiple/rest-api-templates/param_parsing.mustache
    team/dlee/allow-multiple/rest-api-templates/res_stasis_http_resource.c.mustache

Modified: team/dlee/allow-multiple/res/res_stasis_http_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_asterisk.c?view=diff&rev=395449&r1=395448&r2=395449
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_asterisk.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_asterisk.c Thu Jul 25 14:45:34 2013
@@ -62,13 +62,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_get_asterisk_info_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_get_asterisk_info_args args = {};
-	struct ast_variable *i;
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "only") == 0) {
@@ -78,27 +77,28 @@
 
 			args.only_parse = ast_strdup(i->value);
 			if (!args.only_parse) {
-				ast_log(LOG_ERROR, "OOM parsing only\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			args.only_count = ast_app_separate_args(
 				args.only_parse, ',', vals, ARRAY_LEN(vals));
 			if (args.only_count == 0) {
-				ast_log(LOG_ERROR, "Error parsing only\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			if (args.only_count >= MAX_VALS) {
-				ast_log(LOG_ERROR, "Too many values for only\n");
-				args.only_count = 0;
-				continue;
+				stasis_http_response_error(response, 400,
+					"Bad Request",
+					"Too many values for only");
+				goto fin;
 			}
 
 			args.only = ast_malloc(sizeof(*args.only) * args.only_count);
 			if (!args.only) {
-				ast_log(LOG_ERROR, "OOM parsing only\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			for (j = 0; j < args.only_count; ++j) {
@@ -109,8 +109,6 @@
 	}
 	stasis_http_get_asterisk_info(headers, &args, response);
 
-	ast_free(args.only_parse);
-	ast_free(args.only);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -138,6 +136,11 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	ast_free(args.only_parse);
+	ast_free(args.only);
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /asterisk/variable.
@@ -150,13 +153,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_get_global_var_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_get_global_var_args args = {};
-	struct ast_variable *i;
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "variable") == 0) {
@@ -193,6 +195,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /asterisk/variable.
@@ -205,13 +210,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_set_global_var_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_set_global_var_args args = {};
-	struct ast_variable *i;
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "variable") == 0) {
@@ -251,6 +255,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 
 /*! \brief REST handler for /api-docs/asterisk.{format} */

Modified: team/dlee/allow-multiple/res/res_stasis_http_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_bridges.c?view=diff&rev=395449&r1=395448&r2=395449
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_bridges.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_bridges.c Thu Jul 25 14:45:34 2013
@@ -62,12 +62,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_get_bridges_args args = {};
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
 
-	struct ast_get_bridges_args args = {};
 	stasis_http_get_bridges(headers, &args, response);
 
 #if defined(AST_DEVMODE)
@@ -97,6 +97,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges.
@@ -109,13 +112,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_new_bridge_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_new_bridge_args args = {};
-	struct ast_variable *i;
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "type") == 0) {
@@ -152,6 +154,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}.
@@ -164,13 +169,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_get_bridge_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_get_bridge_args args = {};
-	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "bridgeId") == 0) {
@@ -208,6 +212,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}.
@@ -220,13 +227,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_delete_bridge_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_delete_bridge_args args = {};
-	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "bridgeId") == 0) {
@@ -264,6 +270,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}/addChannel.
@@ -276,13 +285,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_add_channel_to_bridge_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_add_channel_to_bridge_args args = {};
-	struct ast_variable *i;
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "channel") == 0) {
@@ -292,27 +300,28 @@
 
 			args.channel_parse = ast_strdup(i->value);
 			if (!args.channel_parse) {
-				ast_log(LOG_ERROR, "OOM parsing channel\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			args.channel_count = ast_app_separate_args(
 				args.channel_parse, ',', vals, ARRAY_LEN(vals));
 			if (args.channel_count == 0) {
-				ast_log(LOG_ERROR, "Error parsing channel\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			if (args.channel_count >= MAX_VALS) {
-				ast_log(LOG_ERROR, "Too many values for channel\n");
-				args.channel_count = 0;
-				continue;
+				stasis_http_response_error(response, 400,
+					"Bad Request",
+					"Too many values for channel");
+				goto fin;
 			}
 
 			args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
 			if (!args.channel) {
-				ast_log(LOG_ERROR, "OOM parsing channel\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			for (j = 0; j < args.channel_count; ++j) {
@@ -329,8 +338,6 @@
 	}
 	stasis_http_add_channel_to_bridge(headers, &args, response);
 
-	ast_free(args.channel_parse);
-	ast_free(args.channel);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -361,6 +368,11 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	ast_free(args.channel_parse);
+	ast_free(args.channel);
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}/removeChannel.
@@ -373,13 +385,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_remove_channel_from_bridge_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_remove_channel_from_bridge_args args = {};
-	struct ast_variable *i;
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "channel") == 0) {
@@ -389,27 +400,28 @@
 
 			args.channel_parse = ast_strdup(i->value);
 			if (!args.channel_parse) {
-				ast_log(LOG_ERROR, "OOM parsing channel\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			args.channel_count = ast_app_separate_args(
 				args.channel_parse, ',', vals, ARRAY_LEN(vals));
 			if (args.channel_count == 0) {
-				ast_log(LOG_ERROR, "Error parsing channel\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			if (args.channel_count >= MAX_VALS) {
-				ast_log(LOG_ERROR, "Too many values for channel\n");
-				args.channel_count = 0;
-				continue;
+				stasis_http_response_error(response, 400,
+					"Bad Request",
+					"Too many values for channel");
+				goto fin;
 			}
 
 			args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
 			if (!args.channel) {
-				ast_log(LOG_ERROR, "OOM parsing channel\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			for (j = 0; j < args.channel_count; ++j) {
@@ -426,8 +438,6 @@
 	}
 	stasis_http_remove_channel_from_bridge(headers, &args, response);
 
-	ast_free(args.channel_parse);
-	ast_free(args.channel);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -455,6 +465,11 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	ast_free(args.channel_parse);
+	ast_free(args.channel);
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}/play.
@@ -467,13 +482,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_play_on_bridge_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_play_on_bridge_args args = {};
-	struct ast_variable *i;
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "media") == 0) {
@@ -527,6 +541,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}/record.
@@ -539,13 +556,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_record_bridge_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_record_bridge_args args = {};
-	struct ast_variable *i;
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "name") == 0) {
@@ -606,6 +622,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 
 /*! \brief REST handler for /api-docs/bridges.{format} */

Modified: team/dlee/allow-multiple/res/res_stasis_http_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_channels.c?view=diff&rev=395449&r1=395448&r2=395449
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_channels.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_channels.c Thu Jul 25 14:45:34 2013
@@ -62,12 +62,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_get_channels_args args = {};
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	stasis_http_get_channels(headers, &args, response);
 
 #if defined(AST_DEVMODE)
@@ -97,6 +97,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels.
@@ -109,13 +112,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_originate_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "endpoint") == 0) {
@@ -174,6 +176,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}.
@@ -186,13 +191,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_get_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
@@ -230,6 +234,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}.
@@ -242,13 +249,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_delete_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
@@ -286,6 +292,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/dial.
@@ -298,13 +307,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_dial_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "endpoint") == 0) {
@@ -358,6 +366,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/continue.
@@ -370,13 +381,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_continue_in_dialplan_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "context") == 0) {
@@ -427,6 +437,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/answer.
@@ -439,13 +452,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_answer_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
@@ -484,6 +496,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/mute.
@@ -496,13 +511,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_mute_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "direction") == 0) {
@@ -547,6 +561,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/unmute.
@@ -559,13 +576,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_unmute_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "direction") == 0) {
@@ -610,6 +626,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/hold.
@@ -622,13 +641,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_hold_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
@@ -667,6 +685,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/unhold.
@@ -679,13 +700,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_unhold_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
@@ -724,6 +744,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/mohstart.
@@ -736,13 +759,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_moh_start_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "mohClass") == 0) {
@@ -787,6 +809,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/mohstop.
@@ -799,13 +824,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_moh_stop_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
@@ -844,6 +868,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/play.
@@ -856,13 +883,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_play_on_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "media") == 0) {
@@ -916,6 +942,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/record.
@@ -928,13 +957,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_record_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "name") == 0) {
@@ -998,6 +1026,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/variable.
@@ -1010,13 +1041,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_get_channel_var_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "variable") == 0) {
@@ -1061,6 +1091,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/variable.
@@ -1073,13 +1106,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_set_channel_var_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "variable") == 0) {
@@ -1127,6 +1159,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 
 /*! \brief REST handler for /api-docs/channels.{format} */

Modified: team/dlee/allow-multiple/res/res_stasis_http_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_endpoints.c?view=diff&rev=395449&r1=395448&r2=395449
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_endpoints.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_endpoints.c Thu Jul 25 14:45:34 2013
@@ -62,12 +62,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_get_endpoints_args args = {};
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
 
-	struct ast_get_endpoints_args args = {};
 	stasis_http_get_endpoints(headers, &args, response);
 
 #if defined(AST_DEVMODE)
@@ -97,6 +97,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /endpoints/{tech}.
@@ -109,13 +112,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_get_endpoints_by_tech_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_get_endpoints_by_tech_args args = {};
-	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "tech") == 0) {
@@ -152,6 +154,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /endpoints/{tech}/{resource}.
@@ -164,13 +169,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_get_endpoint_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_get_endpoint_args args = {};
-	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "tech") == 0) {
@@ -210,6 +214,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 
 /*! \brief REST handler for /api-docs/endpoints.{format} */

Modified: team/dlee/allow-multiple/res/res_stasis_http_events.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_events.c?view=diff&rev=395449&r1=395448&r2=395449
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_events.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_events.c Thu Jul 25 14:45:34 2013
@@ -54,10 +54,28 @@
 static void stasis_http_event_websocket_ws_cb(struct ast_websocket *ws_session,
 	struct ast_variable *get_params, struct ast_variable *headers)
 {
+	struct ast_event_websocket_args args = {};
+	RAII_VAR(struct stasis_http_response *, response, NULL, ast_free);
+	struct ast_variable *i;
 	RAII_VAR(struct ast_websocket *, s, ws_session, ast_websocket_unref);
 	RAII_VAR(struct ari_websocket_session *, session, NULL, ao2_cleanup);
-	struct ast_event_websocket_args args = {};
-	struct ast_variable *i;
+
+	response = ast_calloc(1, sizeof(*response));
+	if (!response) {
+		ast_log(LOG_ERROR, "Failed to create response.\n");
+		goto fin;
+	}
+
+#if defined(AST_DEVMODE)
+	session = ari_websocket_session_create(ws_session,
+		ari_validate_message_fn());
+#else
+	session = ari_websocket_session_create(ws_session, NULL);
+#endif
+	if (!session) {
+		ast_log(LOG_ERROR, "Failed to create ARI session\n");
+		goto fin;
+	}
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "app") == 0) {
@@ -67,27 +85,28 @@
 
 			args.app_parse = ast_strdup(i->value);
 			if (!args.app_parse) {
-				ast_log(LOG_ERROR, "OOM parsing app\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			args.app_count = ast_app_separate_args(
 				args.app_parse, ',', vals, ARRAY_LEN(vals));
 			if (args.app_count == 0) {
-				ast_log(LOG_ERROR, "Error parsing app\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			if (args.app_count >= MAX_VALS) {
-				ast_log(LOG_ERROR, "Too many values for app\n");
-				args.app_count = 0;
-				continue;
+				stasis_http_response_error(response, 400,
+					"Bad Request",
+					"Too many values for app");
+				goto fin;
 			}
 
 			args.app = ast_malloc(sizeof(*args.app) * args.app_count);
 			if (!args.app) {
-				ast_log(LOG_ERROR, "OOM parsing app\n");
-				continue;
+				stasis_http_response_alloc_failed(response);
+				goto fin;
 			}
 
 			for (j = 0; j < args.app_count; ++j) {
@@ -96,18 +115,26 @@
 		} else /* Looks weird, but makes the codegen much simpler */
 		{}
 	}
-#if defined(AST_DEVMODE)
-	session = ari_websocket_session_create(ws_session,
-		ari_validate_message_fn());
-#else
-	session = ari_websocket_session_create(ws_session, NULL);
-#endif
-	if (!session) {
-		ast_log(LOG_ERROR, "Failed to create ARI session\n");
-	} else {
-		ari_websocket_event_websocket(session, headers, &args);
+
+	ari_websocket_event_websocket(session, headers, &args);
+
+fin: __attribute__((unused))
+	if (response && response->response_code != 0) {
+		/* Param parsing failure */
+		/* TODO - ideally, this would return the error code to the
+		 * HTTP client; but we've already done the WebSocket
+		 * negotiation. Param parsing should happen earlier, but we
+		 * need a way to pass it through the WebSocket code to the
+		 * callback */
+		RAII_VAR(char *, msg, NULL, ast_free);
+		if (response->message) {
+			msg = ast_json_dump_string(response->message);
+		} else {
+			msg = ast_strdup("?");
+		}
+		ast_websocket_write(ws_session, AST_WEBSOCKET_OPCODE_TEXT, msg,
+			strlen(msg));
 	}
-
 	ast_free(args.app_parse);
 	ast_free(args.app);
 }

Modified: team/dlee/allow-multiple/res/res_stasis_http_playback.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_playback.c?view=diff&rev=395449&r1=395448&r2=395449
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_playback.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_playback.c Thu Jul 25 14:45:34 2013
@@ -62,13 +62,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_get_playback_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_get_playback_args args = {};
-	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "playbackId") == 0) {
@@ -105,6 +104,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /playback/{playbackId}.
@@ -117,13 +119,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_stop_playback_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_stop_playback_args args = {};
-	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "playbackId") == 0) {
@@ -160,6 +161,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /playback/{playbackId}/control.
@@ -172,13 +176,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_control_playback_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_control_playback_args args = {};
-	struct ast_variable *i;
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "operation") == 0) {
@@ -224,6 +227,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 
 /*! \brief REST handler for /api-docs/playback.{format} */

Modified: team/dlee/allow-multiple/res/res_stasis_http_recordings.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_recordings.c?view=diff&rev=395449&r1=395448&r2=395449
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_recordings.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_recordings.c Thu Jul 25 14:45:34 2013
@@ -62,12 +62,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_get_stored_recordings_args args = {};
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	stasis_http_get_stored_recordings(headers, &args, response);
 
 #if defined(AST_DEVMODE)
@@ -97,6 +97,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /recordings/stored/{recordingName}.
@@ -109,13 +112,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_get_stored_recording_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
@@ -152,6 +154,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /recordings/stored/{recordingName}.
@@ -164,13 +169,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_delete_stored_recording_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
@@ -207,6 +211,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /recordings/live.
@@ -219,12 +226,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_get_live_recordings_args args = {};
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	stasis_http_get_live_recordings(headers, &args, response);
 
 #if defined(AST_DEVMODE)
@@ -254,6 +261,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /recordings/live/{recordingName}.
@@ -266,13 +276,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_get_live_recording_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
@@ -309,6 +318,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /recordings/live/{recordingName}.
@@ -321,13 +333,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_cancel_recording_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
@@ -364,6 +375,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /recordings/live/{recordingName}/stop.
@@ -376,13 +390,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_stop_recording_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
@@ -419,6 +432,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /recordings/live/{recordingName}/pause.
@@ -431,13 +447,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,

[... 340 lines stripped ...]



More information about the asterisk-commits mailing list