diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-12-04 19:57:39 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-12-04 19:57:39 +0000 |
commit | f86cc8722b75f85a66c6427b02390a58454fbb44 (patch) | |
tree | 49818d7a1960eb3edb92942b70bd3b696e6a7444 /main/pbx.c | |
parent | e7e92974ca0abdce3357ce6abcce136ef3588b19 (diff) |
Make some changes to some additions I made recently for doing channel autoservice
when looking up extensions. This code was added to handle the case where a
dialplan switch was in use that could block for a long time. However, the way
that I added it, it did this for all extension lookups. However, lookups in the
in-memory tree of extensions should _not_ take long enough to matter. So, move
the autoservice stuff to be only around executing a switch.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@90967 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/pbx.c')
-rw-r--r-- | main/pbx.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/main/pbx.c b/main/pbx.c index 015d87d13..b08b19566 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -1031,7 +1031,15 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, else /* action == E_MATCH */ aswf = asw->exists; datap = sw->eval ? sw->tmpdata : sw->data; - res = !aswf ? 0 : aswf(chan, context, exten, priority, callerid, datap); + if (!aswf) + res = 0; + else { + if (chan) + ast_autoservice_start(chan); + res = aswf(chan, context, exten, priority, callerid, datap); + if (chan) + ast_autoservice_stop(chan); + } if (res) { /* Got a match */ q->swo = asw; q->data = datap; @@ -1792,30 +1800,21 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con, int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE); - if (c) - ast_autoservice_start(c); - ast_mutex_lock(&conlock); e = pbx_find_extension(c, con, &q, context, exten, priority, label, callerid, action); if (e) { if (matching_action) { ast_mutex_unlock(&conlock); - if (c) - ast_autoservice_stop(c); return -1; /* success, we found it */ } else if (action == E_FINDLABEL) { /* map the label to a priority */ res = e->priority; ast_mutex_unlock(&conlock); - if (c) - ast_autoservice_stop(c); return res; /* the priority we were looking for */ } else { /* spawn */ app = pbx_findapp(e->app); ast_mutex_unlock(&conlock); if (!app) { ast_log(LOG_WARNING, "No application '%s' for extension (%s, %s, %d)\n", e->app, context, exten, priority); - if (c) - ast_autoservice_stop(c); return -1; } if (c->context != context) @@ -1845,23 +1844,17 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con, "AppData: %s\r\n" "Uniqueid: %s\r\n", c->name, c->context, c->exten, c->priority, app->name, passdata, c->uniqueid); - if (c) - ast_autoservice_stop(c); return pbx_exec(c, app, passdata); /* 0 on success, -1 on failure */ } } else if (q.swo) { /* not found here, but in another switch */ ast_mutex_unlock(&conlock); if (matching_action) { - if (c) - ast_autoservice_stop(c); return -1; } else { if (!q.swo->exec) { ast_log(LOG_WARNING, "No execution engine for switch %s\n", q.swo->name); res = -1; } - if (c) - ast_autoservice_stop(c); return q.swo->exec(c, q.foundcontext ? q.foundcontext : context, exten, priority, callerid, q.data); } } else { /* not found anywhere, see what happened */ @@ -1888,9 +1881,6 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con, ast_log(LOG_DEBUG, "Shouldn't happen!\n"); } - if (c) - ast_autoservice_stop(c); - return (matching_action) ? 0 : -1; } } |