Routing: for efficiency, avoid complexifying the "condition" string until the second...
authorJeremy Harris <jgh146exb@wizmail.org>
Thu, 22 Sep 2016 18:29:49 +0000 (19:29 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Thu, 22 Sep 2016 18:29:49 +0000 (19:29 +0100)
src/src/readconf.c
src/src/route.c
test/stderr/0364
test/stderr/0377
test/stderr/0378
test/stderr/0499

index 0a06559f48df83dfd3a16ccfe6faeb522a7d9e7c..3e82b71198f77f41c57e2ebaf01114f6bf6be1aa 100644 (file)
@@ -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)
       {
index 57dfc09e6b1c48b8da786b47ea0dbea7347a4f43..cd44389dbbfe1b267cccd424458b2556dde7e9f4 100644 (file)
@@ -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)
index f648839f10cabee2b97d05e0bb4a99b7ec692196..d6a49bbf65e85f3160db6e5e1c1d16362e3ad819 100644 (file)
@@ -81,7 +81,7 @@ r2 router declined for solik@otherhost.test.ex
 --------> r3 router <--------
 local_part=solik domain=otherhost.test.ex
 checking domains
-checking "condition"
+checking "condition" "${if eq{$address_data}{}{no}{yes}}"...
 processing address_data
 calling r3 router
 rda_interpret (string): $local_part@$original_domain.sub.test.ex
@@ -107,7 +107,7 @@ r2 router declined for solik@otherhost.sub.test.ex
 --------> r3 router <--------
 local_part=solik domain=otherhost.sub.test.ex
 checking domains
-checking "condition"
+checking "condition" "${if eq{$address_data}{}{no}{yes}}"...
 r3 router skipped: condition failure
 --------> r4 router <--------
 local_part=solik domain=otherhost.sub.test.ex
@@ -184,7 +184,7 @@ r2 router declined for xxx@testsub.test.ex
 --------> r3 router <--------
 local_part=xxx domain=testsub.test.ex
 checking domains
-checking "condition"
+checking "condition" "${if eq{$address_data}{}{no}{yes}}"...
 processing address_data
 calling r3 router
 rda_interpret (string): $local_part@$original_domain.sub.test.ex
index ca394989050c84c2b8112a4ffb6942c123b0356d..848ee336786fc5008c054dde464dfaa5974c8190 100644 (file)
@@ -63,7 +63,7 @@ bbbb_0 router skipped: local_parts mismatch
 --------> cccc_2nd_time router <--------
 local_part=cccc domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{no}{yes}}"...
 cccc_2nd_time router skipped: condition failure
 --------> cccc_redirect router <--------
 local_part=cccc domain=myhost.test.ex
@@ -101,7 +101,7 @@ seen_aaaa router skipped: local_parts mismatch
 --------> bbbb router <--------
 local_part=bbbb domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{yes}{no}}"...
 calling bbbb router
 rda_interpret (string): bbbb@$domain, defer_bbbb@$domain
 expanded: bbbb@myhost.test.ex, defer_bbbb@myhost.test.ex
@@ -127,7 +127,7 @@ defer router skipped: local_parts mismatch
 --------> unseen_aaaa router <--------
 local_part=aaaa domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{yes}{no}}"...
 calling unseen_aaaa router
 rda_interpret (string): defer_aaaa@$domain
 expanded: defer_aaaa@myhost.test.ex
@@ -207,7 +207,7 @@ bbbb_0 router skipped: local_parts mismatch
 --------> cccc_2nd_time router <--------
 local_part=cccc domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{no}{yes}}"...
 cccc_2nd_time router skipped: condition failure
 --------> cccc_redirect router <--------
 cccc_redirect router skipped: previously routed cccc@myhost.test.ex
@@ -376,7 +376,7 @@ bbbb_0 router skipped: local_parts mismatch
 --------> cccc_2nd_time router <--------
 local_part=cccc domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{no}{yes}}"...
 calling cccc_2nd_time router
 rda_interpret (string): $local_part@$domain
 expanded: cccc@myhost.test.ex
@@ -406,7 +406,7 @@ seen_aaaa router skipped: local_parts mismatch
 --------> bbbb router <--------
 local_part=bbbb domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{yes}{no}}"...
 bbbb router skipped: condition failure
 --------> bbbb_0 router <--------
 local_part=bbbb domain=myhost.test.ex
@@ -431,7 +431,7 @@ defer router skipped: local_parts mismatch
 --------> unseen_aaaa router <--------
 local_part=aaaa domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{yes}{no}}"...
 unseen_aaaa router skipped: condition failure
 --------> seen_aaaa router <--------
 local_part=aaaa domain=myhost.test.ex
@@ -627,7 +627,7 @@ bbbb_0 router skipped: local_parts mismatch
 --------> cccc_2nd_time router <--------
 local_part=cccc domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{no}{yes}}"...
 calling cccc_2nd_time router
 rda_interpret (string): $local_part@$domain
 expanded: cccc@myhost.test.ex
@@ -657,7 +657,7 @@ seen_aaaa router skipped: local_parts mismatch
 --------> bbbb router <--------
 local_part=bbbb domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{yes}{no}}"...
 bbbb router skipped: condition failure
 --------> bbbb_0 router <--------
 local_part=bbbb domain=myhost.test.ex
@@ -682,7 +682,7 @@ defer router skipped: local_parts mismatch
 --------> unseen_aaaa router <--------
 local_part=aaaa domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{yes}{no}}"...
 unseen_aaaa router skipped: condition failure
 --------> seen_aaaa router <--------
 local_part=aaaa domain=myhost.test.ex
index bb7b4a40aae0d59328e4375e806ce014cb308501..d82f049a720899416f32b74776faa2aec27b24e3 100644 (file)
@@ -35,7 +35,7 @@ defer router skipped: local_parts mismatch
 --------> aaaa_2nd_time router <--------
 local_part=aaaa domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{no}{yes}}"...
 aaaa_2nd_time router skipped: condition failure
 --------> aaaa router <--------
 local_part=aaaa domain=myhost.test.ex
@@ -212,7 +212,7 @@ defer router skipped: local_parts mismatch
 --------> aaaa_2nd_time router <--------
 local_part=aaaa domain=myhost.test.ex
 checking local_parts
-checking "condition"
+checking "condition" "${if first_delivery{no}{yes}}"...
 calling aaaa_2nd_time router
 rda_interpret (string): aaaa@$domain
 expanded: aaaa@myhost.test.ex
index 4592f64698a48307ee7b2f772db549728c28f3f7..2ecd699aab6ac7ac8ad981bf2ae24c7b0a6ab8c2 100644 (file)
@@ -25,7 +25,7 @@ host_find_bydns yield = HOST_FOUND_LOCAL (3); returned hosts:
   eximtesthost.test.ex ip4.ip4.ip4.ip4 MX=5 
 mxt1.test.ex in "@mx_any"? yes (matched "@mx_any")
 mxt1.test.ex in "+anymx"? yes (matched "+anymx")
-checking "condition"
+checking "condition" "${if match_domain{$domain}{+anymx}{yes}}"...
 DNS lookup of mxt1.test.ex (MX) using fakens
 DNS lookup of mxt1.test.ex (MX) succeeded
 DNS lookup of eximtesthost.test.ex (A) using fakens