Don't start/stop autoservice in pbx_extension_helper() unless a channel exists

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@89839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Russell Bryant 19 years ago
parent a5db0a6103
commit 3df74ed9ac

@ -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;
}

Loading…
Cancel
Save