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 0a06559..3e82b71 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 57dfc09..cd44389 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 f648839..d6a49bb 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 ca39498..848ee33 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 bb7b4a4..d82f049 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 4592f64..2ecd699 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