aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authormurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-01 22:26:51 +0000
committermurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-01 22:26:51 +0000
commit47c8ea00b89b1941c88858209af9be34740d7b4a (patch)
tree66604362a97aec13e31eae19ea0258e0042b8397 /apps
parent93798f79e2a924d37153ea63869ee78786837519 (diff)
This commits the performance mods that give the priority processing engine in the pbx, a 25-30% speed boost. The two updates used, are, first, to merge the ast_exists_extension() and the ast_spawn_extension() where they are called sequentially in a loop in the code, into a slightly upgraded version of ast_spawn_extension(), with a few extra args; and, second, I modified the substitute_variables_helper_full, so it zeroes out the byte after the evaluated string instead of demanding you pre-zero the buffer; I also went thru the code and removed the code that zeroed this buffer before every call to the substitute_variables_helper_full. The first fix provides about a 9% speedup, and the second the rest. These figures come from the 'PIPS' benchmark I describe in blogs, conf. reports, etc.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@88166 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_dial.c14
-rw-r--r--apps/app_exec.c4
-rw-r--r--apps/app_macro.c7
-rw-r--r--apps/app_minivm.c3
-rw-r--r--apps/app_mixmonitor.c3
-rw-r--r--apps/app_playback.c1
-rw-r--r--apps/app_queue.c2
-rw-r--r--apps/app_rpt.c2
8 files changed, 15 insertions, 21 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 3a1f12312..ee7c41f59 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1791,20 +1791,20 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
if (ast_test_flag64(&opts, OPT_PEER_H) && ast_exists_extension(peer, peer->context, "h", 1, peer->cid.cid_num)) {
int autoloopflag;
+ int found;
strcpy(peer->exten, "h");
peer->priority = 1;
autoloopflag = ast_test_flag(peer, AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */
ast_set_flag(peer, AST_FLAG_IN_AUTOLOOP);
- while (ast_exists_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num)) {
- if ((res = ast_spawn_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num))) {
- /* Something bad happened, or a hangup has been requested. */
- ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name);
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name);
- break;
- }
+ while ((res = ast_spawn_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num, &found,1))) {
peer->priority++;
}
+ if (found && res) {
+ /* Something bad happened, or a hangup has been requested. */
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name);
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name);
+ }
ast_set2_flag(peer, autoloopflag, AST_FLAG_IN_AUTOLOOP); /* set it back the way it was */
}
if (res != AST_PBX_NO_HANGUP_PEER) {
diff --git a/apps/app_exec.c b/apps/app_exec.c
index 12b91a488..048c33851 100644
--- a/apps/app_exec.c
+++ b/apps/app_exec.c
@@ -92,7 +92,7 @@ static char *execif_descrip =
static int exec_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- char *s, *appname, *endargs, args[MAXRESULT] = "";
+ char *s, *appname, *endargs, args[MAXRESULT];
struct ast_app *app;
if (ast_strlen_zero(data))
@@ -122,7 +122,7 @@ static int exec_exec(struct ast_channel *chan, void *data)
static int tryexec_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- char *s, *appname, *endargs, args[MAXRESULT] = "";
+ char *s, *appname, *endargs, args[MAXRESULT];
struct ast_app *app;
if (ast_strlen_zero(data))
diff --git a/apps/app_macro.c b/apps/app_macro.c
index 32e9d2d21..07284cabc 100644
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -271,6 +271,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
struct ast_context *c;
struct ast_exten *e;
+ int foundx;
runningapp[0] = '\0';
runningdata[0] = '\0';
@@ -299,7 +300,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
/* Reset the macro depth, if it was changed in the last iteration */
pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
- if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num))) {
+ if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num, &foundx,1))) {
/* Something bad happened, or a hangup has been requested. */
if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F')) ||
(res == '*') || (res == '#')) {
@@ -330,7 +331,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
gosub_level++;
ast_debug(1, "Incrementing gosub_level\n");
} else if (!strcasecmp(runningapp, "GOSUBIF")) {
- char tmp2[1024] = "", *cond, *app, *app2 = tmp2;
+ char tmp2[1024], *cond, *app, *app2 = tmp2;
pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1);
cond = strsep(&app2, "?");
app = strsep(&app2, ":");
@@ -353,7 +354,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
ast_debug(1, "Decrementing gosub_level\n");
} else if (!strncasecmp(runningapp, "EXEC", 4)) {
/* Must evaluate args to find actual app */
- char tmp2[1024] = "", *tmp3 = NULL;
+ char tmp2[1024], *tmp3 = NULL;
pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1);
if (!strcasecmp(runningapp, "EXECIF")) {
tmp3 = strchr(tmp2, '|');
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index bb352dc3f..50300a90b 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -1025,7 +1025,6 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
ast_debug(4, "-_-_- Fromaddress template: %s\n", fromaddress);
if ((passdata = alloca(vmlen))) {
- memset(passdata, 0, vmlen);
pbx_substitute_variables_helper(ast, fromaddress, passdata, vmlen);
len_passdata = strlen(passdata) * 2 + 3;
passdata2 = alloca(len_passdata);
@@ -1050,7 +1049,6 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
char *passdata;
int vmlen = strlen(template->subject) * 3 + 200;
if ((passdata = alloca(vmlen))) {
- memset(passdata, 0, vmlen);
pbx_substitute_variables_helper(ast, template->subject, passdata, vmlen);
fprintf(p, "Subject: %s\n", passdata);
} else {
@@ -1082,7 +1080,6 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
char *passdata;
int vmlen = strlen(template->body)*3 + 200;
if ((passdata = alloca(vmlen))) {
- memset(passdata, 0, vmlen);
pbx_substitute_variables_helper(ast, template->body, passdata, vmlen);
ast_debug(3, "Message now: %s\n-----\n", passdata);
fprintf(p, "%s\n", passdata);
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index 13c25d8c7..3c4ef97bc 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -220,7 +220,7 @@ static void launch_monitor_thread(struct ast_channel *chan, const char *filename
{
pthread_t thread;
struct mixmonitor *mixmonitor;
- char postprocess2[1024] = "";
+ char postprocess2[1024];
size_t len;
len = sizeof(*mixmonitor) + strlen(chan->name) + strlen(filename) + 2;
@@ -235,7 +235,6 @@ static void launch_monitor_thread(struct ast_channel *chan, const char *filename
*p2 = '$';
}
}
-
pbx_substitute_variables_helper(chan, p1, postprocess2, sizeof(postprocess2) - 1);
if (!ast_strlen_zero(postprocess2))
len += strlen(postprocess2) + 1;
diff --git a/apps/app_playback.c b/apps/app_playback.c
index 6754d0848..cb49b36ad 100644
--- a/apps/app_playback.c
+++ b/apps/app_playback.c
@@ -202,7 +202,6 @@ static int do_say(say_args_t *a, const char *s, const char *options, int depth)
ast_trim_blanks(x);
/* replace variables */
- memset(fn, 0, sizeof(fn)); /* XXX why isn't done in pbx_substitute_variables_helper! */
pbx_substitute_variables_varshead(&head, x, fn, sizeof(fn));
ast_log(LOG_WARNING, "doing [%s]\n", fn);
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 5ac4c26fb..92374f876 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -2978,7 +2978,6 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
if (p == tmpid2 + sizeof(tmpid2))
tmpid2[sizeof(tmpid2) - 1] = '\0';
- memset(tmpid, 0, sizeof(tmpid));
pbx_substitute_variables_helper(qe->chan, tmpid2, tmpid, sizeof(tmpid) - 1);
}
@@ -3005,7 +3004,6 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
if (p == meid2 + sizeof(meid2))
meid2[sizeof(meid2) - 1] = '\0';
- memset(meid, 0, sizeof(meid));
pbx_substitute_variables_helper(qe->chan, meid2, meid, sizeof(meid) - 1);
}
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index 7d63b961e..14831eb07 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -6936,7 +6936,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
struct ast_hostent ahp;
struct hostent *hp;
struct in_addr ia;
- char hisip[100] = "", nodeip[100];
+ char hisip[100], nodeip[100];
const char *val;
char *s, *s1, *s2;