[Home]

Summary:ASTERISK-16144: [patch] AGISTATUS bug in Asterisk 1.6.2.7
Reporter:S (siby)Labels:
Date Opened:2010-05-25 05:18:20Date Closed:2011-04-13 11:37:12
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Resources/res_agi
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) fastagi-agistatus-test_result-1.txt
( 1) res_agi.c.001.patch
Description:I was just verifying different states of AGISTATUS variable i.e SUCCESS,FAILURE,NOTFOUND and HANGUP.

I have noticed a what looks like a bug in the behaviour for teh case HANGUP.

In this test case, I am trying to hang up the call (from caller side) while it is still executing the AGI script.

When i do this i recive an AGISTATUS of FAILURE when I was expecting HANGUP, as per the 'show application' explination.


Here is a simple setup to replicate the issue,

extensions.conf

[test]
exten => _X.,1,Answer()
exten => _X.,n,AGI(agi-test.php)
exten => _X.,n,NoOp(AGISTATUS: ${AGISTATUS})
exten => _X.,n,Hangup()
exten => h,1,NoOp(AGISTATUS: ${AGISTATUS})

agi-test.php

#!/usr/bin/php
<?php
sleep(7);
?>

Any help/advice would be very much appreciated.
Comments:By: Donny Kavanagh (donnyk) 2010-05-25 08:12:20

Can you enable verbose and error logging in the console and try again.  Then attach the log file please.



By: Donny Kavanagh (donnyk) 2010-05-25 10:34:53

Log by paulbelanger: http://pastebin.com/KBAkPRhz

The AGISTATUS would appear to be set when the hangup occurs and then overwritten before run_agi exists.

By: delvar (delvar) 2010-05-25 11:22:32

iv attached a quick patch that seem to fix the issue of resetting AGISTATUS after hangup, the cause seems to be the line,
if (returnstatus) {
returnstatus = -1;
}

some sort of hack to set FAIL if not success...
surly a better option would be to default to FAIL (-1) and only change it when it needs to ie on hangup.

By: S (siby) 2010-05-25 11:53:57

I have attached the detailed error logging after applying the patch and it seems to receive HANGUP now. For detailed info, please check the fastagi-agistatus-test-result-1.txt file



By: Donny Kavanagh (donnyk) 2010-05-25 12:17:11

Delvar, Thats the code change i would of made, but it looked hackish in the first place and i wasn't sure of the implications :)  There's no doubt that removing that code likely introduces another issue.


Edit: NM, just read the patch, that seems ok, feels hackish though.



By: delvar (delvar) 2010-05-26 04:54:17

juggie, exactly, looks like a hack to fix an issue, thats been hacked because it broke deadagi and now hacked gain to fix the hangup issue.

it seems to work as expected so im not too bothered but maybe this flow could be modified to default to -1 and only change it when its about to exit and set the correct exit code.

but thats probably a lot of work :)

By: Tilghman Lesher (tilghman) 2010-09-14 17:00:18

How about if we just remove the offending statement altogether?  Does that misbehave in any particular way?

By: delvar (delvar) 2010-09-20 06:50:22

im not sure it would have to be tested, the code was added for a reason probably something to do with AGI/DeadAGI integration, removing it may break something else, i don't really have time to test it properly at the moment but the fix above seems to work well for me so im good :)

By: Richard Mudgett (rmudgett) 2011-04-12 11:55:45

The patch I created for ASTERISK-16649 also fixes this issue.

See https://reviewboard.asterisk.org/r/1165/

By: Digium Subversion (svnbot) 2011-04-13 11:21:33

Repository: asterisk
Revision: 313545

U   branches/1.4/main/channel.c
U   branches/1.4/res/res_agi.c

------------------------------------------------------------------------
r313545 | rmudgett | 2011-04-13 11:21:26 -0500 (Wed, 13 Apr 2011) | 41 lines

Asterisk does not hangup a channel after endpoint hangs up.

If the call that the dialplan started an AGI script for is hungup while
the AGI script is in the middle of a command then the AGI script is not
notified of the hangup.  There are many AGI Exec commands that this can
happen with.  The reported applications have been: Background, Wait, Read,
and Dial.  Also the AGI Get Data command.

* Don't wait on the Asterisk channel after it has hung up.  The channel is
likely to never need servicing again.

* Restored the AGI script's ability to return the AGI_RESULT_HANGUP value
in run_agi().  It previously only could return AGI_RESULT_SUCCESS or
AGI_RESULT_FAILURE after the DeadAGI and AGI applications were merged.

(closes issue ASTERISK-16649)
Reported by: mn3250
Patches:
     issue17954_v1.8.patch uploaded by rmudgett (license 664)
     issue17954_v1.6.2.patch uploaded by rmudgett (license 664)
     issue17954_v1.4.patch uploaded by rmudgett (license 664)
Tested by: rmudgett
JIRA SWP-2171

(closes issue ASTERISK-17124)
Reported by: devmod
Tested by: rmudgett
JIRA SWP-2761

(closes issue ASTERISK-17520)
Reported by: nvitaly
Tested by: astmiv, rmudgett
JIRA SWP-3216

(closes issue ASTERISK-16144)
Reported by: siby
Tested by: rmudgett
JIRA SWP-2727

Review: https://reviewboard.asterisk.org/r/1165/

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=313545

By: Digium Subversion (svnbot) 2011-04-13 11:29:56

Repository: asterisk
Revision: 313579

_U  branches/1.6.2/
U   branches/1.6.2/main/channel.c
U   branches/1.6.2/res/res_agi.c

------------------------------------------------------------------------
r313579 | rmudgett | 2011-04-13 11:29:51 -0500 (Wed, 13 Apr 2011) | 48 lines

Merged revisions 313545 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
 r313545 | rmudgett | 2011-04-13 11:21:24 -0500 (Wed, 13 Apr 2011) | 41 lines
 
 Asterisk does not hangup a channel after endpoint hangs up.
 
 If the call that the dialplan started an AGI script for is hungup while
 the AGI script is in the middle of a command then the AGI script is not
 notified of the hangup.  There are many AGI Exec commands that this can
 happen with.  The reported applications have been: Background, Wait, Read,
 and Dial.  Also the AGI Get Data command.
 
 * Don't wait on the Asterisk channel after it has hung up.  The channel is
 likely to never need servicing again.
 
 * Restored the AGI script's ability to return the AGI_RESULT_HANGUP value
 in run_agi().  It previously only could return AGI_RESULT_SUCCESS or
 AGI_RESULT_FAILURE after the DeadAGI and AGI applications were merged.
 
 (closes issue ASTERISK-16649)
 Reported by: mn3250
 Patches:
       issue17954_v1.8.patch uploaded by rmudgett (license 664)
       issue17954_v1.6.2.patch uploaded by rmudgett (license 664)
       issue17954_v1.4.patch uploaded by rmudgett (license 664)
 Tested by: rmudgett
 JIRA SWP-2171
 
 (closes issue ASTERISK-17124)
 Reported by: devmod
 Tested by: rmudgett
 JIRA SWP-2761
 
 (closes issue ASTERISK-17520)
 Reported by: nvitaly
 Tested by: astmiv, rmudgett
 JIRA SWP-3216
 
 (closes issue ASTERISK-16144)
 Reported by: siby
 Tested by: rmudgett
 JIRA SWP-2727
 
 Review: https://reviewboard.asterisk.org/r/1165/
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=313579

By: Digium Subversion (svnbot) 2011-04-13 11:31:55

Repository: asterisk
Revision: 313588

_U  branches/1.8/
U   branches/1.8/main/channel.c
U   branches/1.8/res/res_agi.c

------------------------------------------------------------------------
r313588 | rmudgett | 2011-04-13 11:31:51 -0500 (Wed, 13 Apr 2011) | 55 lines

Merged revisions 313579 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

................
 r313579 | rmudgett | 2011-04-13 11:29:49 -0500 (Wed, 13 Apr 2011) | 48 lines
 
 Merged revisions 313545 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r313545 | rmudgett | 2011-04-13 11:21:24 -0500 (Wed, 13 Apr 2011) | 41 lines
   
   Asterisk does not hangup a channel after endpoint hangs up.
   
   If the call that the dialplan started an AGI script for is hungup while
   the AGI script is in the middle of a command then the AGI script is not
   notified of the hangup.  There are many AGI Exec commands that this can
   happen with.  The reported applications have been: Background, Wait, Read,
   and Dial.  Also the AGI Get Data command.
   
   * Don't wait on the Asterisk channel after it has hung up.  The channel is
   likely to never need servicing again.
   
   * Restored the AGI script's ability to return the AGI_RESULT_HANGUP value
   in run_agi().  It previously only could return AGI_RESULT_SUCCESS or
   AGI_RESULT_FAILURE after the DeadAGI and AGI applications were merged.
   
   (closes issue ASTERISK-16649)
   Reported by: mn3250
   Patches:
         issue17954_v1.8.patch uploaded by rmudgett (license 664)
         issue17954_v1.6.2.patch uploaded by rmudgett (license 664)
         issue17954_v1.4.patch uploaded by rmudgett (license 664)
   Tested by: rmudgett
   JIRA SWP-2171
   
   (closes issue ASTERISK-17124)
   Reported by: devmod
   Tested by: rmudgett
   JIRA SWP-2761
   
   (closes issue ASTERISK-17520)
   Reported by: nvitaly
   Tested by: astmiv, rmudgett
   JIRA SWP-3216
   
   (closes issue ASTERISK-16144)
   Reported by: siby
   Tested by: rmudgett
   JIRA SWP-2727
   
   Review: https://reviewboard.asterisk.org/r/1165/
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=313588

By: Digium Subversion (svnbot) 2011-04-13 11:37:11

Repository: asterisk
Revision: 313606

_U  trunk/
U   trunk/main/channel.c
U   trunk/res/res_agi.c

------------------------------------------------------------------------
r313606 | rmudgett | 2011-04-13 11:37:06 -0500 (Wed, 13 Apr 2011) | 62 lines

Merged revisions 313588 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
 r313588 | rmudgett | 2011-04-13 11:31:50 -0500 (Wed, 13 Apr 2011) | 55 lines
 
 Merged revisions 313579 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.6.2
 
 ................
   r313579 | rmudgett | 2011-04-13 11:29:49 -0500 (Wed, 13 Apr 2011) | 48 lines
   
   Merged revisions 313545 via svnmerge from
   https://origsvn.digium.com/svn/asterisk/branches/1.4
   
   ........
     r313545 | rmudgett | 2011-04-13 11:21:24 -0500 (Wed, 13 Apr 2011) | 41 lines
     
     Asterisk does not hangup a channel after endpoint hangs up.
     
     If the call that the dialplan started an AGI script for is hungup while
     the AGI script is in the middle of a command then the AGI script is not
     notified of the hangup.  There are many AGI Exec commands that this can
     happen with.  The reported applications have been: Background, Wait, Read,
     and Dial.  Also the AGI Get Data command.
     
     * Don't wait on the Asterisk channel after it has hung up.  The channel is
     likely to never need servicing again.
     
     * Restored the AGI script's ability to return the AGI_RESULT_HANGUP value
     in run_agi().  It previously only could return AGI_RESULT_SUCCESS or
     AGI_RESULT_FAILURE after the DeadAGI and AGI applications were merged.
     
     (closes issue ASTERISK-16649)
     Reported by: mn3250
     Patches:
           issue17954_v1.8.patch uploaded by rmudgett (license 664)
           issue17954_v1.6.2.patch uploaded by rmudgett (license 664)
           issue17954_v1.4.patch uploaded by rmudgett (license 664)
     Tested by: rmudgett
     JIRA SWP-2171
     
     (closes issue ASTERISK-17124)
     Reported by: devmod
     Tested by: rmudgett
     JIRA SWP-2761
     
     (closes issue ASTERISK-17520)
     Reported by: nvitaly
     Tested by: astmiv, rmudgett
     JIRA SWP-3216
     
     (closes issue ASTERISK-16144)
     Reported by: siby
     Tested by: rmudgett
     JIRA SWP-2727
     
     Review: https://reviewboard.asterisk.org/r/1165/
   ........
 ................
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=313606