]> git.ipfire.org Git - thirdparty/asterisk.git/commit
Dial API: add self destruct option when complete
authorScott Griepentrog <sgriepentrog@digium.com>
Thu, 26 Feb 2015 18:52:56 +0000 (18:52 +0000)
committerScott Griepentrog <sgriepentrog@digium.com>
Thu, 26 Feb 2015 18:52:56 +0000 (18:52 +0000)
commitc33c5183a51cf1d1343444108a09614538cd1ee2
tree9e09a0f7c65360a08326c1921787c9660cdce767
parent169058e73fbe0b7cb7ff7e57c457093e5296532b
Dial API: add self destruct option when complete

This patch adds a self-destruction option to the
dial api.  The usefulness of this is mostly when
using async mode to spawn a separate thread used
to handle the new call, while the calling thread
is allowed to go on about other business.

The only alternative to this option would be the
calling thread spawning a new thread, or hanging
around itself waiting to destroy the dial struct
after completion.

Example of use (minus error checking):

  struct ast_dial *dial = ast_dial_create();

  ast_dial_append(dial, "PJSIP", "200", NULL);

  ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, "Echo");
  ast_dial_option_global_enable(dial, AST_DIAL_OPTION_SELF_DESTROY, NULL);

  ast_dial_run(dial, NULL, 1);

The dial_run call will return almost immediately
after spawning the new thread to run and monitor
the dial.  If the call is answered, it is placed
into the echo app.  When completed, it will call
ast_dial_destroy() on the dial structure.

Note that any allocations made to pass values to
ast_dial_set_user_data() or dial options must be
free'd in a state callback function on any of:
  AST_DIAL_RESULT_UNASWERED,
  AST_DIAL_RESULT_ANSWERED,
  AST_DIAL_RESULT_HANGUP, or
  AST_DIAL_RESULT_TIMEOUT.

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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@432385 65c4cc65-6c06-0410-ace0-fbb531ad65f3
include/asterisk/dial.h
main/dial.c