[asterisk-commits] dlee: branch dlee/ASTERISK-22036 r396744 - in /team/dlee/ASTERISK-22036: incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 15 10:29:28 CDT 2013


Author: dlee
Date: Thu Aug 15 10:29:26 2013
New Revision: 396744

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396744
Log:
Error check channel against bridge before removing

Modified:
    team/dlee/ASTERISK-22036/include/asterisk/stasis_app.h
    team/dlee/ASTERISK-22036/include/asterisk/stasis_app_impl.h
    team/dlee/ASTERISK-22036/res/ari/resource_bridges.c

Modified: team/dlee/ASTERISK-22036/include/asterisk/stasis_app.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22036/include/asterisk/stasis_app.h?view=diff&rev=396744&r1=396743&r2=396744
==============================================================================
--- team/dlee/ASTERISK-22036/include/asterisk/stasis_app.h (original)
+++ team/dlee/ASTERISK-22036/include/asterisk/stasis_app.h Thu Aug 15 10:29:26 2013
@@ -353,6 +353,16 @@
 	struct stasis_app_control *control, struct ast_bridge *bridge);
 
 /*!
+ * \since 12
+ * \brief Gets the bridge currently associated with a control object.
+ *
+ * \param control Control object for the channel to query.
+ * \return Associated \ref ast_bridge.
+ * \return \c NULL if not associated with a bridge.
+ */
+struct ast_bridge *stasis_app_get_bridge(struct stasis_app_control *control);
+
+/*!
  * \brief Destroy the bridge.
  *
  * \param bridge_id Uniqueid of bridge to be destroyed

Modified: team/dlee/ASTERISK-22036/include/asterisk/stasis_app_impl.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22036/include/asterisk/stasis_app_impl.h?view=diff&rev=396744&r1=396743&r2=396744
==============================================================================
--- team/dlee/ASTERISK-22036/include/asterisk/stasis_app_impl.h (original)
+++ team/dlee/ASTERISK-22036/include/asterisk/stasis_app_impl.h Thu Aug 15 10:29:26 2013
@@ -85,14 +85,4 @@
 int stasis_app_send_command_async(struct stasis_app_control *control,
 	stasis_app_command_cb command, void *data);
 
-/*!
- * \since 12
- * \brief Gets the bridge currently associated with a control object.
- *
- * \param control Control object for the channel to query.
- * \return Associated \ref ast_bridge.
- * \return \c NULL if not associated with a bridge.
- */
-struct ast_bridge *stasis_app_get_bridge(struct stasis_app_control *control);
-
 #endif /* _ASTERISK_RES_STASIS_H */

Modified: team/dlee/ASTERISK-22036/res/ari/resource_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22036/res/ari/resource_bridges.c?view=diff&rev=396744&r1=396743&r2=396744
==============================================================================
--- team/dlee/ASTERISK-22036/res/ari/resource_bridges.c (original)
+++ team/dlee/ASTERISK-22036/res/ari/resource_bridges.c Thu Aug 15 10:29:26 2013
@@ -103,7 +103,7 @@
 		chan = ast_channel_get_by_name(channel_id);
 		if (chan == NULL) {
 			ast_ari_response_error(response, 400, "Bad Request",
-				   "Channel not found");
+				"Channel not found");
 			return NULL;
 		}
 
@@ -218,17 +218,20 @@
 		return;
 	}
 
-	/* BUGBUG this should make sure the bridge requested for removal is actually
-	 * the bridge the channel is in. This will be possible once the bridge uniqueid
-	 * is added to the channel snapshot. A 409 response should be issued if the bridge
-	 * uniqueids don't match */
+	/* Make sure all of the channels are in this bridge */
+	for (i = 0; i < list->count; ++i) {
+		if (stasis_app_get_bridge(list->controls[i]) != bridge) {
+			ast_ari_response_error(response, 422,
+				"Unprocessable Entity",
+				"Channel not in this bridge");
+			return;
+		}
+	}
+
+	/* Now actually remove it */
 	for (i = 0; i < list->count; ++i) {
 		stasis_app_control_remove_channel_from_bridge(list->controls[i],
 			bridge);
-	}
-
-	if (response->response_code) {
-		return;
 	}
 
 	ast_ari_response_no_content(response);




More information about the asterisk-commits mailing list