summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-06-11 17:34:08 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-06-11 17:34:08 +0000
commit72eb8eb1e7ee0e097c1124a9c12cc984a670ee24 (patch)
treec5ccd4f6f09127b22eeaf49b7f37585b1e48d723 /main/channel.c
parentc6142cf2cc7312122abcf74d6ab1daf0ad1d72bf (diff)
Fix deadlock potential with ast_set_hangupsource() calls.
Calling ast_set_hangupsource() with the channel lock held can result in a deadlock because the function also locks the bridged channel. (issue ASTERISK-19537) (closes issue AST-891) Reported by: Guenther Kelleter Tested by: Guenther Kelleter (closes issue ASTERISK-19801) Reported by: Alec Davis ........ Merged revisions 368759 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 368760 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368772 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/main/channel.c b/main/channel.c
index bfca3ec8d..6b3621dae 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -2566,12 +2566,18 @@ void ast_set_hangupsource(struct ast_channel *chan, const char *source, int forc
ast_channel_hangupsource_set(chan, source);
}
bridge = ast_bridged_channel(chan);
+ if (bridge) {
+ ast_channel_ref(bridge);
+ }
ast_channel_unlock(chan);
- if (bridge && (force || ast_strlen_zero(ast_channel_hangupsource(bridge)))) {
+ if (bridge) {
ast_channel_lock(bridge);
- ast_channel_hangupsource_set(chan, source);
+ if (force || ast_strlen_zero(ast_channel_hangupsource(bridge))) {
+ ast_channel_hangupsource_set(bridge, source);
+ }
ast_channel_unlock(bridge);
+ ast_channel_unref(bridge);
}
}