summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2017-08-11 16:31:45 -0500
committerRichard Mudgett <rmudgett@digium.com>2017-08-22 11:59:49 -0500
commit9c70c883697d63e6f16b0b06b688a6131423c7e1 (patch)
tree9993f85fd8ae520f7942479b42f5d0759b4073e3 /main/channel.c
parentc86619bab87d348cbcd2f3378e4b68c8cb20090b (diff)
channel: Fix topology API locking.
* ast_channel_request_stream_topology_change() must not be called with any channel locks held. * ast_channel_stream_topology_changed() must be called with only the passed channel lock held. ASTERISK-27212 Change-Id: I843de7956d9f1cc7cc02025aea3463d8fe19c691
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/main/channel.c b/main/channel.c
index 632d47247..74de9caac 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -10843,22 +10843,29 @@ enum ast_channel_error ast_channel_errno(void)
int ast_channel_request_stream_topology_change(struct ast_channel *chan,
struct ast_stream_topology *topology, void *change_source)
{
+ int res;
+
ast_assert(chan != NULL);
ast_assert(topology != NULL);
+ ast_channel_lock(chan);
if (!ast_channel_is_multistream(chan) || !ast_channel_tech(chan)->indicate) {
+ ast_channel_unlock(chan);
return -1;
}
if (ast_stream_topology_equal(ast_channel_get_stream_topology(chan), topology)) {
ast_debug(3, "Topology of %s already matches what is requested so ignoring topology change request\n",
ast_channel_name(chan));
+ ast_channel_unlock(chan);
return 0;
}
ast_channel_internal_set_stream_topology_change_source(chan, change_source);
- return ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, topology, sizeof(topology));
+ res = ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, topology, sizeof(topology));
+ ast_channel_unlock(chan);
+ return res;
}
int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology)