Review Board 1.7.16

Remove the need for AST_PBX_KEEPALIVE when using GoSub from Dial

Review Request #98 - Created Dec. 18, 2008 and submitted

Russell Bryant
I'm on a mission to have AST_PBX_KEEPALIVE and related return codes completely removed from the tree.  It is currently being used in a couple of different ways.

1) It is used when another thread assumes ownership of a channel from within a dialplan application (such as Parking).  The return code tells the caller that the channel that was passed in is no longer valid and must not be dereferenced.  In my opinion, this is evil and error prone.  By using Masquerading, we can avoid having to deal with these magic "please don't touch this object anymore" return codes.  Murf has a patch which removes all usage of this style in review 29.

2) The Dial() option to run GoSub() also used this return code.  This was because the code needs to run a PBX for GoSub to work, but it also wants to continue doing stuff with the channel after it finishes.  So, it used a final result of KEEPALIVE to achieve this.  However, since we know up front that this is what we want, we can provide it as an option to ast_pbx_run().

This patch updates the ast_pbx API to include an option that can be supplied to ast_pbx_run() to tell the PBX not to free the channel at the end.  It also removes the KeepAlive application, as it is no longer needed.  Finally, it updates app_dial to use this new method for handling GoSub from Dial.
I called 5004 and it worked as expected.


exten => s,1,Playback(tt-weasels)
exten => s,n,Return()


exten => 5004,1,Dial(SIP/5004,,U(silly-playback))
Posted (Dec. 18, 2008, 7:25 a.m.)


/trunk/apps/app_dial.c (Diff revision 1)
Since you are no longer adding the extension in you shouldn't need the context any longer either. You also need to remove the code that finds and deletes/destroys the extension and context from the unload_module callback.
  1. Nevermind! Misread.
Ship it!
Posted (Dec. 18, 2008, 7:27 a.m.)
Go forth and destroy! runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to