diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2016-09-22 19:29:49 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2016-09-22 19:29:49 +0100 |
commit | adaa0e2c25fb6cf60aa9e3c4088915733d073022 (patch) | |
tree | 12212c8da03312a472725e96435ba8f2cf93e9cf /src | |
parent | 2d009132e2de39646108f9c5a829f0611735e730 (diff) |
Routing: for efficiency, avoid complexifying the "condition" string until the second is read from config
Diffstat (limited to 'src')
-rw-r--r-- | src/src/readconf.c | 22 | ||||
-rw-r--r-- | src/src/route.c | 2 |
2 files changed, 11 insertions, 13 deletions
diff --git a/src/src/readconf.c b/src/src/readconf.c index 0a06559f4..3e82b7119 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -1462,7 +1462,6 @@ int intbase = 0; uschar *inttype = US""; uschar *sptr; uschar *s = buffer; -uschar *saved_condition, *strtemp; uschar **str_target; uschar name[64]; uschar name2[64]; @@ -1597,19 +1596,18 @@ switch (type) control block and flags word. */ case opt_stringptr: - if (data_block == NULL) - str_target = (uschar **)(ol->value); - else - str_target = (uschar **)((uschar *)data_block + (long int)(ol->value)); + str_target = data_block ? USS (US data_block + (long int)(ol->value)) + : USS (ol->value); if (ol->type & opt_rep_con) { + uschar * saved_condition; /* We already have a condition, we're conducting a crude hack to let multiple condition rules be chained together, despite storing them in text form. */ - saved_condition = *str_target; - strtemp = string_sprintf("${if and{{bool_lax{%s}}{bool_lax{%s}}}}", - saved_condition, sptr); - *str_target = string_copy_malloc(strtemp); + *str_target = string_copy_malloc( (saved_condition = *str_target) + ? string_sprintf("${if and{{bool_lax{%s}}{bool_lax{%s}}}}", + saved_condition, sptr) + : sptr); /* TODO(pdp): there is a memory leak here and just below when we set 3 or more conditions; I still don't understand the store mechanism enough to know @@ -1645,10 +1643,10 @@ switch (type) break; case opt_rewrite: - if (data_block == NULL) - *((uschar **)(ol->value)) = sptr; + if (data_block) + *USS (US data_block + (long int)(ol->value)) = sptr; else - *((uschar **)((uschar *)data_block + (long int)(ol->value))) = sptr; + *USS (ol->value) = sptr; freesptr = FALSE; if (type == opt_rewrite) { diff --git a/src/src/route.c b/src/src/route.c index 57dfc09e6..cd44389db 100644 --- a/src/src/route.c +++ b/src/src/route.c @@ -979,7 +979,7 @@ if ((rc = check_files(r->require_files, perror)) != OK) if (r->condition) { - DEBUG(D_route) debug_printf("checking \"condition\"\n"); + DEBUG(D_route) debug_printf("checking \"condition\" \"%.80s\"...\n", r->condition); if (!expand_check_condition(r->condition, r->name, US"router")) { if (search_find_defer) |