mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
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:
@@ -693,9 +693,7 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
|
||||
}
|
||||
}
|
||||
|
||||
ast_channel_lock(chan);
|
||||
ast_set_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY);
|
||||
ast_channel_unlock(chan);
|
||||
ast_channel_set_flag(chan, AST_FLAG_END_DTMF_ONLY);
|
||||
|
||||
csth.volfactor = *volfactor;
|
||||
|
||||
@@ -825,9 +823,7 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
|
||||
else
|
||||
ast_deactivate_generator(chan);
|
||||
|
||||
ast_channel_lock(chan);
|
||||
ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY);
|
||||
ast_channel_unlock(chan);
|
||||
ast_channel_clear_flag(chan, AST_FLAG_END_DTMF_ONLY);
|
||||
|
||||
if (ast_test_flag(flags, OPTION_WHISPER | OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
|
||||
ast_audiohook_lock(&csth.whisper_audiohook);
|
||||
@@ -921,7 +917,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
|
||||
if (ast_channel_state(chan) != AST_STATE_UP)
|
||||
ast_answer(chan);
|
||||
|
||||
ast_set_flag(ast_channel_flags(chan), AST_FLAG_SPYING); /* so nobody can spy on us while we are spying */
|
||||
ast_channel_set_flag(chan, AST_FLAG_SPYING);
|
||||
|
||||
waitms = 100;
|
||||
|
||||
@@ -934,7 +930,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
|
||||
if (!res)
|
||||
res = ast_waitstream(chan, "");
|
||||
else if (res < 0) {
|
||||
ast_clear_flag(ast_channel_flags(chan), AST_FLAG_SPYING);
|
||||
ast_channel_clear_flag(chan, AST_FLAG_SPYING);
|
||||
break;
|
||||
}
|
||||
if (!ast_strlen_zero(exitcontext)) {
|
||||
@@ -977,7 +973,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
|
||||
res = ast_waitfordigit(chan, waitms);
|
||||
if (res < 0) {
|
||||
iter = ast_channel_iterator_destroy(iter);
|
||||
ast_clear_flag(ast_channel_flags(chan), AST_FLAG_SPYING);
|
||||
ast_channel_clear_flag(chan, AST_FLAG_SPYING);
|
||||
break;
|
||||
}
|
||||
if (!ast_strlen_zero(exitcontext)) {
|
||||
@@ -1196,7 +1192,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
|
||||
}
|
||||
exit:
|
||||
|
||||
ast_clear_flag(ast_channel_flags(chan), AST_FLAG_SPYING);
|
||||
ast_channel_clear_flag(chan, AST_FLAG_SPYING);
|
||||
|
||||
ast_channel_setoption(chan, AST_OPTION_TXGAIN, &zero_volume, sizeof(zero_volume), 0);
|
||||
|
||||
|
Reference in New Issue
Block a user