mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-06 01:45:11 +00:00
Pass the hangup cause all the way to the calling app/channel.
(closes issue #11328) Reported by: rain Patches: 20071207__pass_cause_in_hangup_control_frame.diff.txt uploaded by Corydon76 (license 14) brought up-to-date to trunk by me git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114637 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1000,12 +1000,19 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
|
||||
}
|
||||
|
||||
/*! \brief Queue a hangup frame for channel */
|
||||
int ast_queue_hangup(struct ast_channel *chan)
|
||||
int ast_queue_hangup(struct ast_channel *chan, int cause)
|
||||
{
|
||||
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
|
||||
|
||||
if (cause >= 0)
|
||||
f.seqno = cause;
|
||||
|
||||
/* Yeah, let's not change a lock-critical value without locking */
|
||||
if (!ast_channel_trylock(chan)) {
|
||||
chan->_softhangup |= AST_SOFTHANGUP_DEV;
|
||||
if (cause < 0)
|
||||
f.seqno = chan->hangupcause;
|
||||
|
||||
ast_channel_unlock(chan);
|
||||
}
|
||||
return ast_queue_frame(chan, &f);
|
||||
@@ -2307,7 +2314,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
|
||||
struct ast_frame *f = NULL; /* the return value */
|
||||
int blah;
|
||||
int prestate;
|
||||
int count = 0;
|
||||
int count = 0, cause = 0;
|
||||
|
||||
/* this function is very long so make sure there is only one return
|
||||
* point at the end (there are only two exceptions to this).
|
||||
@@ -2418,6 +2425,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
|
||||
/* Interpret hangup and return NULL */
|
||||
/* XXX why not the same for frames from the channel ? */
|
||||
if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) {
|
||||
cause = f->seqno;
|
||||
ast_frfree(f);
|
||||
f = NULL;
|
||||
}
|
||||
@@ -2687,6 +2695,8 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
|
||||
} else {
|
||||
/* Make sure we always return NULL in the future */
|
||||
chan->_softhangup |= AST_SOFTHANGUP_DEV;
|
||||
if (cause)
|
||||
chan->hangupcause = cause;
|
||||
if (chan->generator)
|
||||
ast_deactivate_generator(chan);
|
||||
/* End the CDR if appropriate */
|
||||
|
||||
Reference in New Issue
Block a user