summaryrefslogtreecommitdiff
path: root/main/pbx.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2008-12-18 19:33:42 +0000
committerRussell Bryant <russell@russellbryant.com>2008-12-18 19:33:42 +0000
commit50a25ac8474d7900ba59a68ed4fd942074082435 (patch)
tree8df8a6f08733bc20953ce3dbc4125ecb520e35b3 /main/pbx.c
parent8cc50d467719c2031df5ed52f33798f9ce5487be (diff)
Remove the need for AST_PBX_KEEPALIVE with the GoSub option from Dial.
This is part of an effort to completely remove AST_PBX_KEEPALIVE and other similar return codes from the source. While this usage was perfectly safe, there are others that are problematic. Since we know ahead of time that we do not want to PBX to destroy the channel, the PBX API has been changed so that information can be provided as an argument, instead, thus removing the need for the KEEPALIVE return value. Further changes to get rid of KEEPALIVE and related code is being done by murf. There is a patch up for that on review 29. Review: http://reviewboard.digium.com/r/98/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@165723 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/pbx.c')
-rw-r--r--main/pbx.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/main/pbx.c b/main/pbx.c
index 273418366..45c87faed 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -388,16 +388,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
a longer match.</para>
</description>
</application>
- <application name="KeepAlive" language="en_US">
- <synopsis>
- Returns AST_PBX_KEEPALIVE value.
- </synopsis>
- <syntax />
- <description>
- <para>This application is chiefly meant for internal use with Gosubs. Please do not run
- it alone from the dialplan!</para>
- </description>
- </application>
<application name="NoOp" language="en_US">
<synopsis>
Do Nothing (No Operation).
@@ -931,7 +921,6 @@ static int pbx_builtin_background(struct ast_channel *, void *);
static int pbx_builtin_wait(struct ast_channel *, void *);
static int pbx_builtin_waitexten(struct ast_channel *, void *);
static int pbx_builtin_incomplete(struct ast_channel *, void *);
-static int pbx_builtin_keepalive(struct ast_channel *, void *);
static int pbx_builtin_resetcdr(struct ast_channel *, void *);
static int pbx_builtin_setamaflags(struct ast_channel *, void *);
static int pbx_builtin_ringing(struct ast_channel *, void *);
@@ -1097,7 +1086,6 @@ static struct pbx_builtin {
{ "ImportVar", pbx_builtin_importvar },
{ "Hangup", pbx_builtin_hangup },
{ "Incomplete", pbx_builtin_incomplete },
- { "KeepAlive", pbx_builtin_keepalive },
{ "NoOp", pbx_builtin_noop },
{ "Proceeding", pbx_builtin_proceeding },
{ "Progress", pbx_builtin_progress },
@@ -4139,7 +4127,8 @@ static int collect_digits(struct ast_channel *c, int waittime, char *buf, int bu
return 0;
}
-static int __ast_pbx_run(struct ast_channel *c)
+static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
+ struct ast_pbx_args *args)
{
int found = 0; /* set if we find at least one match */
int res = 0;
@@ -4352,11 +4341,18 @@ static int __ast_pbx_run(struct ast_channel *c)
}
}
}
- if (!found && !error)
+
+ if (!found && !error) {
ast_log(LOG_WARNING, "Don't know what to do with '%s'\n", c->name);
- if (res != AST_PBX_KEEPALIVE)
+ }
+
+ if (!args || !args->no_hangup_chan) {
ast_softhangup(c, c->hangupcause ? c->hangupcause : AST_CAUSE_NORMAL_CLEARING);
- if ((res != AST_PBX_KEEPALIVE) && !ast_test_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN) && ast_exists_extension(c, c->context, "h", 1, c->cid.cid_num)) {
+ }
+
+ if ((!args || !args->no_hangup_chan) &&
+ !ast_test_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN) &&
+ ast_exists_extension(c, c->context, "h", 1, c->cid.cid_num)) {
set_ext_pri(c, "h", 1);
while ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num, &found, 1)) == 0) {
c->priority++;
@@ -4371,8 +4367,11 @@ static int __ast_pbx_run(struct ast_channel *c)
ast_clear_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN); /* from one round to the next, make sure this gets cleared */
pbx_destroy(c->pbx);
c->pbx = NULL;
- if (res != AST_PBX_KEEPALIVE)
+
+ if (!args || !args->no_hangup_chan) {
ast_hangup(c);
+ }
+
return 0;
}
@@ -4462,7 +4461,7 @@ static void *pbx_thread(void *data)
*/
struct ast_channel *c = data;
- __ast_pbx_run(c);
+ __ast_pbx_run(c, NULL);
decrease_call_count();
pthread_exit(NULL);
@@ -4492,19 +4491,26 @@ enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
return AST_PBX_SUCCESS;
}
-enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
+enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args)
{
enum ast_pbx_result res = AST_PBX_SUCCESS;
- if (increase_call_count(c))
+ if (increase_call_count(c)) {
return AST_PBX_CALL_LIMIT;
+ }
+
+ res = __ast_pbx_run(c, args);
- res = __ast_pbx_run(c);
decrease_call_count();
return res;
}
+enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
+{
+ return ast_pbx_run_args(c, NULL);
+}
+
int ast_active_calls(void)
{
return countcalls;
@@ -8310,11 +8316,6 @@ static int pbx_builtin_answer(struct ast_channel *chan, void *data)
return __ast_answer(chan, delay);
}
-static int pbx_builtin_keepalive(struct ast_channel *chan, void *data)
-{
- return AST_PBX_KEEPALIVE;
-}
-
static int pbx_builtin_incomplete(struct ast_channel *chan, void *data)
{
char *options = data;