[Home]

Summary:ASTERISK-17520: [patch] HANGUP is not sent to AGI in time
Reporter:Vitaly Nikolaev (nvitaly)Labels:
Date Opened:2011-03-07 12:08:39.000-0600Date Closed:2011-04-13 11:37:11
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Resources/res_agi
Versions:1.6.2.17 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) agi_does_not_detect_hangup_test1.php
( 1) hangupdelay.txt
( 2) phpagi.php
( 3) phpagi-asmanager.php
Description:I have IVR application that request PIN from customer. If customer hangup during prompt request, asterisk sends empty response to AGI, then according to dialplan it re-ask PIN few times, always getting empty response since channel is down, Playbacks end up with:
[Mar  7 12:49:57] WARNING[23939]: app_playback.c:471 playback_exec: ast_streamfile failed on SIP/ivrin-00000001 for ss-pininvalid

And only after some time (from few second to the minute) asterisk sends HANGUP to AGI client.

It used to be instant in Asterisk 1.6.2.11

Attaching SIP/AGI debug info.
Let me know if you need more tests.


****** ADDITIONAL INFORMATION ******

CentOS 5.5 64bit
Comments:By: Leif Madsen (lmadsen) 2011-03-08 11:51:57.000-0600

It will be far easier to track this down if you determine which revision caused this regression. Please checkout various revisions of Asterisk by looking at changes that may be related and testing them to determine what caused this. Providing this information will cause your issue to be more likely to be resolved in a timely manner.

By: Maciej Krajewski (jamicque) 2011-04-06 03:49:41

The situation happens to me too while running AGI GET DATA command.
Asterisk does not pass hangup to AGI.

By: Michel Verbraak (astmiv) 2011-04-07 08:57:42

With the attached php script (agi_does_not_detect_hangup_test1.php) this problem can be reproduced on a SIP channel. I do not have other channels currently available to test on.

dialplan example:
[default]
exten 100,1,AGI(agi_does_not_detect_hangup_test1.php)

Open a CLI (verbose 50) and from a sip client dial 100 and hangup. Watch CLI it will continue looping.
This is visible in 1.8.3.2 and trunk.

As far as I could find the problem is in asterisk/res/res_agi.c in function agi_result run_agi on the line "c = ast_waitfor_nandfds(&chan, dead ? 0 : 1, &agi->ctrl, 1, NULL, &outfd, &ms);" The call to this function never returns. It does not detect that the SIP channel is gone because the poll/select used by the function only listens to events POLLIN | POLLPRI and has a very long timeout (ms=-1). When an UDP connection is hungup these events are never triggerd.

(OS: Debian squeeze X64)



By: Michel Verbraak (astmiv) 2011-04-08 01:59:11

Solved by issue https://reviewboard.asterisk.org/r/1165/

By: Richard Mudgett (rmudgett) 2011-04-08 13:08:58

The issue17954_v1.8.patch file is the patch on reviewboard.

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

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:55

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:54

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:09

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