[asterisk-commits] kmoore: trunk r410528 - in /trunk: ./ res/ res/stasis/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 13 14:33:27 CDT 2014
Author: kmoore
Date: Thu Mar 13 14:33:22 2014
New Revision: 410528
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=410528
Log:
ARI: Ensure managing application receives ChannelEnteredBridge messages
This fixes an issue where a Stasis application running over ARI and
subscribed to ari/events could miss the ChannelEnteredBridge event
because it did not subscribe to the new bridge fast enough.
To accomplish this, it subscribes the application controlling the
channel to the new bridge before adding it to that bridge which
required the stasis_app_control structure to maintain a reference to
the stasis_app.
(closes issue ASTERISK-23295)
Review: https://reviewboard.asterisk.org/r/3336/
........
Merged revisions 410527 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
trunk/ (props changed)
trunk/res/res_stasis.c
trunk/res/stasis/control.c
trunk/res/stasis/control.h
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: trunk/res/res_stasis.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_stasis.c?view=diff&rev=410528&r1=410527&r2=410528
==============================================================================
--- trunk/res/res_stasis.c (original)
+++ trunk/res/res_stasis.c Thu Mar 13 14:33:22 2014
@@ -258,7 +258,7 @@
struct stasis_app_control *stasis_app_control_create(struct ast_channel *chan)
{
- return control_create(chan);
+ return control_create(chan, NULL);
}
struct stasis_app_control *stasis_app_control_find_by_channel(
@@ -742,7 +742,7 @@
return -1;
}
- control = control_create(chan);
+ control = control_create(chan, app);
if (!control) {
ast_log(LOG_ERROR, "Allocated failed\n");
return -1;
Modified: trunk/res/stasis/control.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/stasis/control.c?view=diff&rev=410528&r1=410527&r2=410528
==============================================================================
--- trunk/res/stasis/control.c (original)
+++ trunk/res/stasis/control.c Thu Mar 13 14:33:22 2014
@@ -31,6 +31,7 @@
#include "command.h"
#include "control.h"
+#include "app.h"
#include "asterisk/dial.h"
#include "asterisk/bridge.h"
#include "asterisk/bridge_after.h"
@@ -73,6 +74,10 @@
*/
struct ast_silence_generator *silgen;
/*!
+ * The app for which this control was created
+ */
+ struct stasis_app *app;
+ /*!
* When set, /c app_stasis should exit and continue in the dialplan.
*/
int is_done:1;
@@ -91,9 +96,10 @@
ao2_cleanup(control->command_queue);
ast_cond_destroy(&control->wait_cond);
-}
-
-struct stasis_app_control *control_create(struct ast_channel *channel)
+ ao2_cleanup(control->app);
+}
+
+struct stasis_app_control *control_create(struct ast_channel *channel, struct stasis_app *app)
{
RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
int res;
@@ -102,6 +108,8 @@
if (!control) {
return NULL;
}
+
+ control->app = ao2_bump(app);
res = ast_cond_init(&control->wait_cond, NULL);
if (res != 0) {
@@ -798,6 +806,8 @@
ast_channel_pbx_set(control->channel, control->pbx);
control->pbx = NULL;
+ app_unsubscribe_bridge(control->app, control->bridge);
+
/* No longer in the bridge */
control->bridge = NULL;
@@ -864,6 +874,12 @@
* for the memory fence.
*/
SCOPED_AO2LOCK(lock, control);
+
+ /* Ensure the controlling application is subscribed early enough
+ * to receive the ChannelEnteredBridge message. This works in concert
+ * with the subscription handled in the Stasis application execution
+ * loop */
+ app_subscribe_bridge(control->app, bridge);
/* Save off the channel's PBX */
ast_assert(control->pbx == NULL);
Modified: trunk/res/stasis/control.h
URL: http://svnview.digium.com/svn/asterisk/trunk/res/stasis/control.h?view=diff&rev=410528&r1=410527&r2=410528
==============================================================================
--- trunk/res/stasis/control.h (original)
+++ trunk/res/stasis/control.h Thu Mar 13 14:33:22 2014
@@ -33,10 +33,12 @@
* \brief Create a control object.
*
* \param channel Channel to control.
+ * \param app stasis_app for which this control is being created.
+ *
* \return New control object.
* \return \c NULL on error.
*/
-struct stasis_app_control *control_create(struct ast_channel *channel);
+struct stasis_app_control *control_create(struct ast_channel *channel, struct stasis_app *app);
/*!
* \brief Dispatch all commands enqueued to this control.
More information about the asterisk-commits
mailing list