[Home]

Summary:ASTERISK-11601: redirect through AMI not working reliable in 1.4
Reporter:Michael Neuhauser (mneuhauser)Labels:
Date Opened:2008-03-09 11:21:42Date Closed:2008-04-11 16:35:40
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/PBX
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:I'm developing an AMI application
that dispatches calls with redirect while they wait in the dialplan,
something like this (in AEL syntax):
       UserEvent(DispatchMe);
       Wait(5);
       Log(ERROR|AMI did not dispatch call);
       // fallback to dialplan-only based call routing
When doing an automated redirect over AMI (triggered by the UserEvent), then the call is sometimes hung up:
DEBUG[17160]: pbx.c:1831 pbx_extension_helper: Launching 'UserEvent'
DEBUG[17117]: manager.c:2107 process_message: Manager received command 'Redirect'
DEBUG[17117]: channel.c:1378 ast_softhangup_nolock: Soft-Hanging up channel 'SIP/10.0.0.30-008b0570'
DEBUG[17160]: pbx.c:2454 __ast_pbx_run: Extension park-call, priority 0 returned normally even though call was hung up
DEBUG[17160]: channel.c:1378 ast_softhangup_nolock: Soft-Hanging up channel 'SIP/10.0.0.30-008b0570'
DEBUG[17160]: channel.c:1477 ast_hangup: Hanging up channel 'SIP/10.0.0.30-008b0570'

The redirect works reliable (without hang ups) when the AMI application performs the redirect delayed by 100 ms and not right after the user event is received (parameters like logging level, system load etc. were kept constant).

Looking at __ast_pbx_run() one can see that the AST_SOFTHANGUP_ASYNCGOTO case is only handled if the spawned application returned non-zero. In the other case, i.e., when zero is returned, any different _softhangup value than AST_SOFTHANGUP_TIMEOUT leads to a hangup of the channel:

   if ((res = ast_spawn_extension(...) {
       ...
       if (c->_softhangup == AST_SOFTHANGUP_ASYNCGOTO) {
           c->_softhangup =0;
       } else ...
   }
   /* *** no check for AST_SOFTHANGUP_ASYNCGOTO *** */
   if (c->_softhangup == AST_SOFTHANGUP_TIMEOUT ...) {
   } else if (c->_softhangup) {
       ast_log(LOG_DEBUG...returned normally even though call was hung up").
       error = 1;

This explains why delaying the redirect makes my application work: then the Wait() application in my dialplan is always running and return a non-zero value. While without the delay, there is a race between my AMI application and Asterisk and the other code branch could be taken.
Comments:By: Digium Subversion (svnbot) 2008-04-11 16:30:30

Repository: asterisk
Revision: 114072

U   branches/1.4/main/pbx.c

------------------------------------------------------------------------
r114072 | qwell | 2008-04-11 16:30:28 -0500 (Fri, 11 Apr 2008) | 4 lines

It's possible that a channel can have an async goto on the successful execution of an application as well.

Closes issue ASTERISK-11601.

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

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

By: Digium Subversion (svnbot) 2008-04-11 16:34:59

Repository: asterisk
Revision: 114073

_U  trunk/

------------------------------------------------------------------------
r114073 | qwell | 2008-04-11 16:34:56 -0500 (Fri, 11 Apr 2008) | 13 lines

Blocked revisions 114072 via svnmerge

Already fixed here.

........
r114072 | qwell | 2008-04-11 16:35:16 -0500 (Fri, 11 Apr 2008) | 4 lines

It's possible that a channel can have an async goto on the successful execution of an application as well.

Closes issue ASTERISK-11601.

........

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

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

By: Digium Subversion (svnbot) 2008-04-11 16:35:40

Repository: asterisk
Revision: 114074

_U  branches/1.6.0/

------------------------------------------------------------------------
r114074 | qwell | 2008-04-11 16:35:38 -0500 (Fri, 11 Apr 2008) | 21 lines

Merged revisions 114073 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
r114073 | qwell | 2008-04-11 16:39:44 -0500 (Fri, 11 Apr 2008) | 13 lines

Blocked revisions 114072 via svnmerge

Already fixed here.

........
r114072 | qwell | 2008-04-11 16:35:16 -0500 (Fri, 11 Apr 2008) | 4 lines

It's possible that a channel can have an async goto on the successful execution of an application as well.

Closes issue ASTERISK-11601.

........

................

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

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