diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-22 14:19:06 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-22 14:19:06 +0000 |
commit | 419d94437add00389a05f868320e2787336c2fa2 (patch) | |
tree | 7c6b64f778f4f7dba93d0972f198c4bef6db06fa /res/res_agi.c | |
parent | 751dfcc96bd9a4c8983620b18ddcb2a9e8b5a2b4 (diff) |
Merged revisions 166258 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r166258 | russell | 2008-12-22 08:16:54 -0600 (Mon, 22 Dec 2008) | 26 lines
Remove AST_PBX_KEEPALIVE usage from res_agi.
This patch removes the usage of AST_PBX_KEEPALIVE from res_agi. The only usage
was for the AGI command, "asyncagi break". This patch removes this feature.
Normally, a feature would not be removed like this. However, this code is
broken and usage of it will result in a memory leak.
Usage of this feature will make the AGI code return a result of
AST_PBX_KEEPALIVE. The PBX handler assumes that another thread has assumed
ownership of the channel. The channel thread will exit without destroying the
channel. Unfortunately, _no_ thread has ownership of the channel at this
point. There are a couple of serious problems here:
1) The only way to recover the caller is to issue a channel redirect. This
will work, but this will be done with a masquerade, and the old ast_channel
structure will be lost.
2) Until the channel redirect happens, there is no code servicing the channel.
That means nothing is reading audio or handling events coming from the
channel. This is very bad.
The recommended way to get this same "break" functionality is to issue the
redirect while the channel is still being handled by the AGI code. That way,
there will be no memory leak, and there will be no period of time that the
channel is not being serviced.
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@166260 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_agi.c')
-rw-r--r-- | res/res_agi.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/res/res_agi.c b/res/res_agi.c index d9a74fcfb..f6abe272f 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -445,7 +445,7 @@ static enum agi_result launch_asyncagi(struct ast_channel *chan, char *argv[], i /* OK, we have a command, let's call the command handler. */ res = agi_handle_command(chan, &async_agi, cmd->cmd_buffer, 0); - if ((res < 0) || (res == AST_PBX_KEEPALIVE)) { + if (res < 0) { free_agi_cmd(cmd); break; } @@ -1987,12 +1987,6 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc, return RESULT_SUCCESS; } -static int handle_asyncagi_break(struct ast_channel *chan, AGI *agi, int argc, char *argv[]) -{ - ast_agi_send(agi->fd, chan, "200 result=0\n"); - return AST_PBX_KEEPALIVE; -} - static char usage_setmusic[] = " Usage: SET MUSIC ON <on|off> <class>\n" " Enables/Disables the music on hold generator. If <class> is\n" @@ -2236,10 +2230,6 @@ static char usage_autohangup[] = " future. Of course it can be hungup before then as well. Setting to 0 will\n" " cause the autohangup feature to be disabled on this channel.\n"; -static char usage_break_aagi[] = -" Usage: ASYNCAGI BREAK\n" -" Break the Async AGI loop.\n"; - static char usage_noop[] = " Usage: NoOp\n" " Does nothing.\n"; @@ -2325,7 +2315,6 @@ static struct agi_command commands[] = { { { "speech", "activate", "grammar", NULL }, handle_speechactivategrammar, "Activates a grammar", usage_speechactivategrammar, 0 }, { { "speech", "deactivate", "grammar", NULL }, handle_speechdeactivategrammar, "Deactivates a grammar", usage_speechdeactivategrammar, 0 }, { { "speech", "recognize", NULL }, handle_speechrecognize, "Recognizes speech", usage_speechrecognize, 0 }, - { { "asyncagi", "break", NULL }, handle_asyncagi_break, "Break AsyncAGI loop", usage_break_aagi, 0 }, }; static AST_RWLIST_HEAD_STATIC(agi_commands, agi_command); @@ -2576,7 +2565,6 @@ static int agi_handle_command(struct ast_channel *chan, AGI *agi, char *buf, int ast_module_unref(c->mod); switch (res) { case RESULT_SHOWUSAGE: ami_res = "Usage"; resultcode = 520; break; - case AST_PBX_KEEPALIVE: ami_res = "KeepAlive"; resultcode = 210; break; case RESULT_FAILURE: ami_res = "Failure"; resultcode = -1; break; case RESULT_SUCCESS: ami_res = "Success"; resultcode = 200; break; } @@ -2593,10 +2581,6 @@ static int agi_handle_command(struct ast_channel *chan, AGI *agi, char *buf, int ast_agi_send(agi->fd, chan, "%s", c->usage); ast_agi_send(agi->fd, chan, "520 End of proper usage.\n"); break; - case AST_PBX_KEEPALIVE: - /* We've been asked to keep alive, so do so */ - return AST_PBX_KEEPALIVE; - break; case RESULT_FAILURE: /* They've already given the failure. We've been hung up on so handle this appropriately */ @@ -2701,8 +2685,9 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi if (!buf[0]) { /* Program terminated */ - if (returnstatus && returnstatus != AST_PBX_KEEPALIVE) + if (returnstatus) { returnstatus = -1; + } ast_verb(3, "<%s>AGI Script %s completed, returning %d\n", chan->name, request, returnstatus); if (pid > 0) waitpid(pid, status, 0); @@ -2724,7 +2709,7 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi ast_verbose("<%s>AGI Rx << %s\n", chan->name, buf); returnstatus |= agi_handle_command(chan, agi, buf, dead); /* If the handle_command returns -1, we need to stop */ - if ((returnstatus < 0) || (returnstatus == AST_PBX_KEEPALIVE)) { + if (returnstatus < 0) { needhup = 1; continue; } |