aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-27 23:16:00 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-27 23:16:00 +0000
commitf3eea3c59b764b3fe17c5626bbc5000eaf34a0a1 (patch)
tree466156be7615234fa021cae0fe7460dd1777641d
parent9a837f7eb4677c684ab49c29f13b3ae8e0bc1bc8 (diff)
Don't start/stop autoservice in pbx_extension_helper() unless a channel exists
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@89839 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/pbx.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/main/pbx.c b/main/pbx.c
index 32b58a0f4..025bcef21 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -1792,26 +1792,30 @@ 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);
- ast_autoservice_start(c);
+ 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);
- ast_autoservice_stop(c);
+ 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);
- ast_autoservice_stop(c);
+ 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);
- ast_autoservice_stop(c);
+ if (c)
+ ast_autoservice_stop(c);
return -1;
}
if (c->context != context)
@@ -1847,20 +1851,23 @@ 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);
- ast_autoservice_stop(c);
+ 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) {
- ast_autoservice_stop(c);
+ 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;
}
- ast_autoservice_stop(c);
+ 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 */
@@ -1887,7 +1894,8 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
ast_log(LOG_DEBUG, "Shouldn't happen!\n");
}
- ast_autoservice_stop(c);
+ if (c)
+ ast_autoservice_stop(c);
return (matching_action) ? 0 : -1;
}