diff options
author | Joshua Colp <jcolp@digium.com> | 2017-05-13 16:40:00 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2017-05-16 14:25:23 +0000 |
commit | 5a7af00e80b9f360a11fcbbc6c6b6dfd2ee478a6 (patch) | |
tree | 6f5b088ad13c1451d1e8421e57b9cd1a9a2d3434 /main/pbx.c | |
parent | ce4d8dac91631599452a9c7aa9c81001704afb62 (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 'main/pbx.c')
-rw-r--r-- | main/pbx.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/main/pbx.c b/main/pbx.c index 28027c06b..ccfba054e 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -4300,8 +4300,10 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c, ast_channel_pbx(c)->rtimeoutms = 10000; ast_channel_pbx(c)->dtimeoutms = 5000; + ast_channel_lock(c); autoloopflag = ast_test_flag(ast_channel_flags(c), AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */ ast_set_flag(ast_channel_flags(c), AST_FLAG_IN_AUTOLOOP); + ast_channel_unlock(c); if (ast_strlen_zero(ast_channel_exten(c))) { /* If not successful fall back to 's' - but only if there is no given exten */ @@ -4546,8 +4548,10 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c, ast_pbx_hangup_handler_run(c); } + ast_channel_lock(c); ast_set2_flag(ast_channel_flags(c), autoloopflag, AST_FLAG_IN_AUTOLOOP); ast_clear_flag(ast_channel_flags(c), AST_FLAG_BRIDGE_HANGUP_RUN); /* from one round to the next, make sure this gets cleared */ + ast_channel_unlock(c); pbx_destroy(ast_channel_pbx(c)); ast_channel_pbx_set(c, NULL); |