Review Board 1.7.16


dial api: add self destruction option

Review Request #4443 - Created Feb. 23, 2015 and submitted

Scott Griepentrog
13, trunk
Reviewers
asterisk-dev
Asterisk
This adds a self-destruction ability to the dial api.  The usefulness of this is mostly when using async mode to spawn a separate thread to handle the new call, while the calling thread is allowed to go on about other business.  The alternative of this option is that the calling thread must either hang around for the duration or spawn it's own thread in order to create and then later destroy the dial structure after the call completes.

Example (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 returns almost immediately after spawning a new thread to complete and monitor the dial.  If the call is answered, it is put into echo.  When completed, ast_dial_destroy() will be called on the dial structure.

Note that any allocations made to pass values to ast_dial_set_user_data() or other dial options will need to 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.
Correct operation confirmed with a temporary test function running under valgrind to insure there are no invalid references or leaks.
Review request changed
Updated (Feb. 26, 2015, 1:23 p.m.)
  • changed from pending to submitted
Committed in revision 432403

https://reviewboard.asterisk.org/ 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 asteriskteam@digium.com.