asterisk: Audit locking of channel when manipulating flags.

When manipulating flags on a channel the channel has to be
locked to guarantee that nothing else is also manipulating
the flags. This change introduces locking where necessary to
guarantee this. It also adds helper functions that manipulate
channel flags and lock to reduce repeated code.

ASTERISK-26789

Change-Id: I489280662dba0f4c50981bfc5b5a7073fef2db10
This commit is contained in:
Joshua Colp
2017-05-13 16:40:00 +00:00
parent ce4d8dac91
commit 5a7af00e80
15 changed files with 95 additions and 55 deletions

View File

@@ -1558,8 +1558,10 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con
}
}
if (!res) {
ast_channel_lock(chan);
ast_channel_latest_musicclass_set(chan, mohclass->name);
ast_set_flag(ast_channel_flags(chan), AST_FLAG_MOH);
ast_channel_unlock(chan);
}
mohclass = mohclass_unref(mohclass, "unreffing local reference to mohclass in local_ast_moh_start");
@@ -1569,10 +1571,10 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con
static void local_ast_moh_stop(struct ast_channel *chan)
{
ast_clear_flag(ast_channel_flags(chan), AST_FLAG_MOH);
ast_deactivate_generator(chan);
ast_channel_lock(chan);
ast_clear_flag(ast_channel_flags(chan), AST_FLAG_MOH);
if (ast_channel_music_state(chan)) {
if (ast_channel_stream(chan)) {
ast_closestream(ast_channel_stream(chan));