[Home]

Summary:ASTERISK-18811: Dialplan is not processed after AGI script when dst channel hangup first
Reporter:David Hajek (hajekd)Labels:
Date Opened:2011-11-03 08:27:58Date Closed:2011-12-08 11:59:16.000-0600
Priority:MajorRegression?
Status:Closed/CompleteComponents:Resources/res_agi
Versions:1.8.7.0 Frequency of
Occurrence
Related
Issues:
is related toASTERISK-19173 All blind transfers failing on 1.8.9.0-rc1
Environment:Attachments:( 0) jira_asterisk_18811_v1.8.patch
Description:Dialplan is not being processed after AGI script when destination phone hangup first.

Example:
{code}
[test]
exten => 501,1,Dial(SIP/501)
exten => 501,n,Hangup
exten => h,1,NoOp("Hangup starting...")
exten => h,n,AGI(waitfor60sec.php)
exten => h,n,NoOp("Cleanup code....")
{code}

{noformat}
-- Called SIP/501
   -- SIP/501-00000015 is ringing
   -- SIP/501-00000015 is ringing
   -- SIP/501-00000015 answered SIP/500-00000014
   -- Locally bridging SIP/500-00000014 and SIP/501-00000015
   -- Executing [h@test:1] NoOp("SIP/500-00000014", ""Hangup starting..."") in new stack
   -- Executing [h@test:2] AGI("SIP/500-00000014", "waitfor60sec.php") in new stack
   -- Launched AGI Script /var/lib/asterisk/agi-bin/waitfor60sec.php
   -- <SIP/500-00000014>AGI Script waitfor60sec.php completed, returning 4
 == Spawn extension (test, h, 2) exited non-zero on 'SIP/500-00000014'
 == Spawn extension (test, 501, 1) exited non-zero on 'SIP/500-00000014'
{noformat}

The above example shows that destination phone hangup first and dialplan after AGI(waitfor60sec.php) is not being processed. This is causing lot of issues in cleanup code. When source phone hangup first than it works fine. It even works in all asterisk 1.6.0.x versions.

I think the problem is in res/res_agi.c here:

{code}
switch (res) {
       case AGI_RESULT_SUCCESS:
       case AGI_RESULT_SUCCESS_FAST:
       case AGI_RESULT_SUCCESS_ASYNC:
               pbx_builtin_setvar_helper(chan, "AGISTATUS", "SUCCESS");
               break;
       case AGI_RESULT_FAILURE:
               pbx_builtin_setvar_helper(chan, "AGISTATUS", "FAILURE");
               break;
       case AGI_RESULT_NOTFOUND:
               pbx_builtin_setvar_helper(chan, "AGISTATUS", "NOTFOUND");
               break;
       case AGI_RESULT_HANGUP:
               pbx_builtin_setvar_helper(chan, "AGISTATUS", "HANGUP");
               return -1; <<<<<<<<<<<<< WHY WE HAVE return -1 HERE <<<<<<<<<<<<<<<<<<<<<<<
       }

       return 0;
{code}

Thanks,
David
Comments:By: David Hajek (hajekd) 2011-11-29 16:27:13.948-0600

Does this bug rings any bells?

I assume it is OK to run AGI script in h extension and expect that dialplan will be processed even after channel hangups. It works fine with System() but its hard to read/set dialplan variables and overall using System() seems to me weird. It works just fine in Asterisk 1.6....


By: David Hajek (hajekd) 2011-11-30 07:09:18.307-0600

Adding more info:

- same buggy behaviour even with Asterisk 10
- when replacing AGI(wait60.php) with System(sleep 60) it works and NoOp("Cleanup code...") is shown under all cases
- when adding "g" option to Dial(...,,g) then it seems to work with AGI(wait60.php) and NoOp("Cleanup code...") is shown under all cases

Anyway it seems to me like a bug.

By: Richard Mudgett (rmudgett) 2011-12-05 15:39:45.465-0600

[^jira_asterisk_18811_v1.8.patch] should fix the issue.

FYI.  An important step missing in your description was that you needed to hangup the caller channel while the AGI script was running.

By: Richard Mudgett (rmudgett) 2011-12-05 15:40:00.088-0600

Please test.

By: David Hajek (hajekd) 2011-12-07 16:26:24.468-0600

It works! I'm not able to reproduce the problem again. Thanks!