diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-01-28 17:15:41 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-01-28 17:15:41 +0000 |
commit | 8b1d81f4eed25b1f883d68871a9e5d4c655e888b (patch) | |
tree | 3f2ce6672be5fc2196c5c81011a47e0d6a580af0 /main/channel.c | |
parent | 940f913146cc96cda9132600151d40ee85680ee6 (diff) |
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: http://svn.digium.com/svn/asterisk/branches/1.4@100581 f38db490-d61c-443f-a65b-d21fe96a405b
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 40aa67f7b..d5af9cb2e 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1556,16 +1556,23 @@ 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) { if (option_debug) ast_log(LOG_DEBUG, "Auto-deactivating generator\n"); ast_deactivate_generator(chan); } + return 0; } @@ -1975,13 +1982,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 |