summaryrefslogtreecommitdiff
path: root/apps/app_chanspy.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-05-13 16:40:00 +0000
committerJoshua Colp <jcolp@digium.com>2017-05-16 14:25:01 +0000
commit161820396495a549c9a378d32136cbb5f28ef2af (patch)
treed6df892de3055d9765d58d5592ec33b6e4676d20 /apps/app_chanspy.c
parent6383d9214aaba9a7ace1753ff0f6dfe1f2c6c5fa (diff)
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
Diffstat (limited to 'apps/app_chanspy.c')
-rw-r--r--apps/app_chanspy.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 608eb6be1..2a472bf44 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -676,9 +676,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;
@@ -808,9 +806,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);
@@ -904,7 +900,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;
@@ -917,7 +913,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)) {
@@ -960,7 +956,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)) {
@@ -1179,7 +1175,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);