int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE);
- ast_autoservice_start(c);
+ if (c)
+ ast_autoservice_start(c);
ast_rdlock_contexts();
if (found)
*found = 1;
if (matching_action) {
ast_unlock_contexts();
- 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_unlock_contexts();
- ast_autoservice_stop(c);
+ if (c)
+ ast_autoservice_stop(c);
return res; /* the priority we were looking for */
} else { /* spawn */
if (!e->cached_app)
ast_unlock_contexts();
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)
"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_unlock_contexts();
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 */
ast_debug(1, "Shouldn't happen!\n");
}
- ast_autoservice_stop(c);
+ if (c)
+ ast_autoservice_stop(c);
return (matching_action) ? 0 : -1;
}