[asterisk-commits] kpfleming: trunk r127113 - /trunk/main/channel.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 1 14:53:04 CDT 2008
Author: kpfleming
Date: Tue Jul 1 14:53:03 2008
New Revision: 127113
URL: http://svn.digium.com/view/asterisk?view=rev&rev=127113
Log:
change the process of inserting a delay into the ast_answer() path so that we don't tell the calling channel that it has been answered unutil after the delay; for a single-thread call this won't matter all, but for a dual-thread call (using chan_local) this may fix the problem in issue 12924
Modified:
trunk/main/channel.c
Modified: trunk/main/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/main/channel.c?view=diff&rev=127113&r1=127112&r2=127113
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Tue Jul 1 14:53:03 2008
@@ -1696,15 +1696,31 @@
switch (chan->_state) {
case AST_STATE_RINGING:
case AST_STATE_RING:
- if (chan->tech->answer)
- res = chan->tech->answer(chan);
- ast_setstate(chan, AST_STATE_UP);
- ast_cdr_answer(chan->cdr);
- ast_channel_unlock(chan);
- if (delay)
+ if (delay) {
+ int needanswer = (chan->tech->answer != NULL);
+
+ ast_setstate(chan, AST_STATE_UP);
+ ast_cdr_answer(chan->cdr);
+ ast_channel_unlock(chan);
ast_safe_sleep(chan, delay);
+ /* don't tell the channel it has been answered until *after* the delay,
+ so that the media path will be in place and usable when it wants to
+ send media
+ */
+ if (needanswer) {
+ ast_channel_lock(chan);
+ res = chan->tech->answer(chan);
+ ast_channel_unlock(chan);
+ }
+ } else {
+ if (chan->tech->answer) {
+ res = chan->tech->answer(chan);
+ }
+ ast_setstate(chan, AST_STATE_UP);
+ ast_cdr_answer(chan->cdr);
+ ast_channel_unlock(chan);
+ }
return res;
- break;
case AST_STATE_UP:
ast_cdr_answer(chan->cdr);
break;
More information about the asterisk-commits
mailing list