diff options
author | Russell Bryant <russell@russellbryant.com> | 2008-01-28 17:21:24 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2008-01-28 17:21:24 +0000 |
commit | 1c74c549d7e18392a157b3a54b5d2a34d061916c (patch) | |
tree | 71630b456aae80ecb9da5fe4c0b4fce68bbada92 /main/channel.c | |
parent | f877028d76b9f37ecf352409a30a0c215b0033cf (diff) |
Merged revisions 100581 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r100581 | russell | 2008-01-28 11:15:41 -0600 (Mon, 28 Jan 2008) | 9 lines
Make some deadlock related fixes. These bugs were discovered and reported
internally at Digium by Steve Pitts.
- Fix up chan_local to ensure that the channel lock is held before the local
pvt lock.
- Don't hold the channel lock when executing the timing function, as it can
cause a deadlock when using chan_local. This actually changes the code back
to be how it was before the change for issue #10765. But, I added some other
locking that I think will prevent the problem reported there, as well.
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@100582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r-- | main/channel.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/main/channel.c b/main/channel.c index 3553a3f1b..446c0d4fa 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1564,15 +1564,22 @@ static int generator_force(const void *data) int res; int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples); struct ast_channel *chan = (struct ast_channel *)data; + + ast_channel_lock(chan); tmp = chan->generatordata; chan->generatordata = NULL; generate = chan->generator->generate; + ast_channel_unlock(chan); + res = generate(chan, tmp, 0, 160); + chan->generatordata = tmp; + if (res) { ast_debug(1, "Auto-deactivating generator\n"); ast_deactivate_generator(chan); } + return 0; } @@ -2200,13 +2207,17 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) } else if (blah == ZT_EVENT_TIMER_EXPIRED) { ioctl(chan->timingfd, ZT_TIMERACK, &blah); if (chan->timingfunc) { - chan->timingfunc(chan->timingdata); + /* save a copy of func/data before unlocking the channel */ + int (*func)(const void *) = chan->timingfunc; + void *data = chan->timingdata; + ast_channel_unlock(chan); + func(data); } else { blah = 0; ioctl(chan->timingfd, ZT_TIMERCONFIG, &blah); chan->timingdata = NULL; + ast_channel_unlock(chan); } - ast_channel_unlock(chan); /* cannot 'goto done' because the channel is already unlocked */ return &ast_null_frame; } else |