diff options
author | Mark Michelson <mmichelson@digium.com> | 2013-12-03 17:07:29 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2013-12-03 17:07:29 +0000 |
commit | 8e8b329e14ad2e4d747c4c4eb33c118305401aee (patch) | |
tree | 200a9b111d9cf75ab980aedf53ee714b7cc398f2 /main/channel.c | |
parent | 8b24b0d20647697c9ee899dea85871465c3032cb (diff) |
Add channel locking for channel snapshot creation.
This adds channel locks around calls to create channel snapshots as well
as other functions which operate on a channel and then end up
creating a channel snapshot. Functions that expect the channel to be
locked prior to being called have had their documentation updated to
indicate such.
........
Merged revisions 403311 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403314 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r-- | main/channel.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/main/channel.c b/main/channel.c index 58b50c820..f1bbbda27 100644 --- a/main/channel.c +++ b/main/channel.c @@ -678,7 +678,9 @@ int ast_str2cause(const char *name) static struct stasis_message *create_channel_snapshot_message(struct ast_channel *channel) { RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup); + ast_channel_lock(channel); snapshot = ast_channel_snapshot_create(channel); + ast_channel_unlock(channel); if (!snapshot) { return NULL; } @@ -1261,6 +1263,7 @@ int ast_queue_hold(struct ast_channel *chan, const char *musicclass) struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HOLD }; int res; + ast_channel_lock(chan); if (!ast_strlen_zero(musicclass)) { f.data.ptr = (void *) musicclass; f.datalen = strlen(musicclass) + 1; @@ -1272,6 +1275,7 @@ int ast_queue_hold(struct ast_channel *chan, const char *musicclass) ast_channel_publish_blob(chan, ast_channel_hold_type(), blob); res = ast_queue_frame(chan, &f); + ast_channel_unlock(chan); return res; } @@ -1280,9 +1284,11 @@ int ast_queue_unhold(struct ast_channel *chan) struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_UNHOLD }; int res; + ast_channel_lock(chan); ast_channel_publish_blob(chan, ast_channel_unhold_type(), NULL); res = ast_queue_frame(chan, &f); + ast_channel_unlock(chan); return res; } @@ -2248,7 +2254,9 @@ static void ast_channel_destructor(void *obj) /* Things that may possibly raise Stasis messages shouldn't occur after this point */ ast_set_flag(ast_channel_flags(chan), AST_FLAG_DEAD); + ast_channel_lock(chan); ast_channel_publish_snapshot(chan); + ast_channel_unlock(chan); publish_cache_clear(chan); ast_channel_lock(chan); @@ -5318,7 +5326,9 @@ static int set_format(struct ast_channel *chan, generator_write_format_change(chan); } + ast_channel_lock(chan); ast_channel_publish_snapshot(chan); + ast_channel_unlock(chan); return 0; } @@ -5399,7 +5409,9 @@ static int set_format(struct ast_channel *chan, generator_write_format_change(chan); } + ast_channel_lock(chan); ast_channel_publish_snapshot(chan); + ast_channel_unlock(chan); return res; } @@ -5616,7 +5628,9 @@ struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_chan /* Copy/inherit important information into new channel */ if (oh) { if (oh->vars) { + ast_channel_lock(new_chan); ast_set_variables(new_chan, oh->vars); + ast_channel_unlock(new_chan); } if (oh->parent_channel) { call_forward_inherit(new_chan, oh->parent_channel, orig); @@ -5677,7 +5691,9 @@ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_c if (oh) { if (oh->vars) { + ast_channel_lock(chan); ast_set_variables(chan, oh->vars); + ast_channel_unlock(chan); } if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) { /* @@ -5949,7 +5965,9 @@ struct ast_channel *ast_request(const char *type, struct ast_format_cap *request if (requestor) { struct ast_callid *callid = ast_channel_callid(requestor); if (callid) { + ast_channel_lock(c); ast_channel_callid_set(c, callid); + ast_channel_unlock(c); callid = ast_callid_unref(callid); } } |