[asterisk-commits] Stasis: Use control queue to prevent crash. (asterisk[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Jan 23 10:07:52 CST 2016
Joshua Colp has submitted this change and it was merged.
Change subject: Stasis: Use control queue to prevent crash.
......................................................................
Stasis: Use control queue to prevent crash.
A crash occurred when attempting to set a channel variable on a channel
that had already been hung up. This is because there is a small window
between when a control is grabbed and when the channel variable is set
that the channel can be hung up.
The fix here is to queue the setting of the channel variable onto the
control queue. This way, the manipulation of the channel happens in a
thread where it is safe to be done.
In this change, I also noticed that the setting of bridge roles on
channels was being done outside of the control queue, so I also changed
those operations to be done in the control queue.
ASTERISK-25709 #close
Reported by Mark Michelson
Change-Id: I2a0a4d51bce6fba6f1d9954e40935e42f366ea78
---
M res/stasis/control.c
1 file changed, 47 insertions(+), 3 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Anonymous Coward #1000019: Verified
Joshua Colp: Looks good to me, approved
diff --git a/res/stasis/control.c b/res/stasis/control.c
index 99407df..030ea8f 100644
--- a/res/stasis/control.c
+++ b/res/stasis/control.c
@@ -355,14 +355,39 @@
return 0;
}
+static int app_control_add_role(struct stasis_app_control *control,
+ struct ast_channel *chan, void *data)
+{
+ char *role = data;
+
+ return ast_channel_add_bridge_role(chan, role);
+}
+
int stasis_app_control_add_role(struct stasis_app_control *control, const char *role)
{
- return ast_channel_add_bridge_role(control->channel, role);
+ char *role_dup;
+
+ role_dup = ast_strdup(role);
+ if (!role_dup) {
+ return -1;
+ }
+
+ stasis_app_send_command_async(control, app_control_add_role, role_dup, ast_free_ptr);
+
+ return 0;
+}
+
+static int app_control_clear_roles(struct stasis_app_control *control,
+ struct ast_channel *chan, void *data)
+{
+ ast_channel_clear_bridge_roles(chan);
+
+ return 0;
}
void stasis_app_control_clear_roles(struct stasis_app_control *control)
{
- ast_channel_clear_bridge_roles(control->channel);
+ stasis_app_send_command_async(control, app_control_clear_roles, NULL, NULL);
}
int control_command_count(struct stasis_app_control *control)
@@ -598,9 +623,28 @@
return 0;
}
+static int app_control_set_channel_var(struct stasis_app_control *control,
+ struct ast_channel *chan, void *data)
+{
+ struct ast_variable *var = data;
+
+ pbx_builtin_setvar_helper(control->channel, var->name, var->value);
+
+ return 0;
+}
+
int stasis_app_control_set_channel_var(struct stasis_app_control *control, const char *variable, const char *value)
{
- return pbx_builtin_setvar_helper(control->channel, variable, value);
+ struct ast_variable *var;
+
+ var = ast_variable_new(variable, value, "ARI");
+ if (!var) {
+ return -1;
+ }
+
+ stasis_app_send_command_async(control, app_control_set_channel_var, var, ast_free_ptr);
+
+ return 0;
}
static int app_control_hold(struct stasis_app_control *control,
--
To view, visit https://gerrit.asterisk.org/2057
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2a0a4d51bce6fba6f1d9954e40935e42f366ea78
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
More information about the asterisk-commits
mailing list