Make batch delivery work for files and pipes set up by redirection.
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Thu, 20 Apr 2006 14:11:29 +0000 (14:11 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Thu, 20 Apr 2006 14:11:29 +0000 (14:11 +0000)
13 files changed:
doc/doc-txt/ChangeLog
doc/doc-txt/NewStuff
src/src/deliver.c
src/src/transports/appendfile.c
test/confs/0534 [new file with mode: 0644]
test/log/0411
test/log/0534 [new file with mode: 0644]
test/mail/0411.afolder
test/mail/0534.mbox [new file with mode: 0644]
test/mail/0534.mbox2 [new file with mode: 0644]
test/runtest
test/scripts/0000-Basic/0411
test/scripts/0000-Basic/0534 [new file with mode: 0644]

index f51f970716f49029a8d6f59a621778ca0faa3b64..8fb90d75007ccf3680638645231267d23ce6a80a 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.343 2006/04/20 10:57:46 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.344 2006/04/20 14:11:29 ph10 Exp $
 
 Change log file for Exim from version 4.21
 -------------------------------------------
@@ -28,6 +28,11 @@ PH/04 Change PH/19 for 4.61 was too wide. It should not be applied to host
       errors. Otherwise a message that provokes a temporary error (when other
       messages do not) can cause a whole host to time out.
 
+PH/05 Batch deliveries by appendfile and pipe transports did not work when the
+      addresses were routed directly to files or pipes from a redirect router.
+      File deliveries just didn't batch; pipe deliveries might have suffered
+      odd errors.
+
 
 Exim version 4.61
 -----------------
index 38c20991bed585bab482d76ba74273bd8f5475c4..dc03699f374ab3212bbee11bc5e35c4d5e76abf9 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/NewStuff,v 1.100 2006/04/18 11:13:19 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/NewStuff,v 1.101 2006/04/20 14:11:29 ph10 Exp $
 
 New Features in Exim
 --------------------
@@ -25,6 +25,10 @@ Version 4.62
    a connection has been made, the behaviour is as for ${readsocket with a Unix
    domain socket.
 
+2. If a redirect router sets up file or pipe deliveries for more than one
+   incoming address, and the relevant transport has batch_max set greater than
+   one, a batch delivery now occurs.
+
 
 Version 4.61
 ------------
index 0cb0132c454cd376f668aadc031ce2b3ef10731a..a80d97842f370e89599d5ac1e42be95b191b41b5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/deliver.c,v 1.30 2006/03/01 16:07:16 ph10 Exp $ */
+/* $Cambridge: exim/src/src/deliver.c,v 1.31 2006/04/20 14:11:29 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -228,11 +228,18 @@ if (addr->next == NULL)
   }
 
 /* For multiple addresses, don't set local part, and leave the domain and
-self_hostname set only if it is the same for all of them. */
+self_hostname set only if it is the same for all of them. It is possible to
+have multiple pipe and file addresses, but only when all addresses have routed
+to the same pipe or file. */
 
 else
   {
   address_item *addr2;
+  if (testflag(addr, af_pfr))
+    {
+    if (testflag(addr, af_file)) address_file = addr->local_part;
+      else if (addr->local_part[0] == '|') address_pipe = addr->local_part;
+    }
   for (addr2 = addr->next; addr2 != NULL; addr2 = addr2->next)
     {
     if (deliver_domain != NULL &&
@@ -2119,15 +2126,17 @@ while (addr_local != NULL)
 
   disable_logging = tp->disable_logging;
 
-  /* Check for batched addresses and possible amalgamation. File deliveries can
-  never be batched. Skip all the work if either batch_max <= 1 or there aren't
-  any other addresses for local delivery. */
+  /* Check for batched addresses and possible amalgamation. Skip all the work
+  if either batch_max <= 1 or there aren't any other addresses for local
+  delivery. */
 
-  if (!testflag(addr, af_file) && tp->batch_max > 1 && addr_local != NULL)
+  if (tp->batch_max > 1 && addr_local != NULL)
     {
     int batch_count = 1;
     BOOL uses_dom = readconf_depends((driver_instance *)tp, US"domain");
-    BOOL uses_lp = readconf_depends((driver_instance *)tp, US"local_part");
+    BOOL uses_lp = (testflag(addr, af_pfr) &&
+      (testflag(addr, af_file) || addr->local_part[0] == '|')) ||
+      readconf_depends((driver_instance *)tp, US"local_part");
     uschar *batch_id = NULL;
     address_item **anchor = &addr_local;
     address_item *last = addr;
@@ -2156,6 +2165,7 @@ while (addr_local != NULL)
       same transport
       not previously delivered (see comment about 50 lines above)
       same local part if the transport's configuration contains $local_part
+        or if this is a file or pipe delivery from a redirection
       same domain if the transport's configuration contains $domain
       same errors address
       same additional headers
@@ -2169,6 +2179,7 @@ while (addr_local != NULL)
       BOOL ok =
         tp == next->transport &&
         !previously_transported(next, TRUE) &&
+        (addr->flags & (af_pfr|af_file)) == (next->flags & (af_pfr|af_file)) &&
         (!uses_lp  || Ustrcmp(next->local_part, addr->local_part) == 0) &&
         (!uses_dom || Ustrcmp(next->domain, addr->domain) == 0) &&
         same_strings(next->p.errors_address, addr->p.errors_address) &&
index 7a415de7ae6c3cfce3127384e58e77a53f5a82fe..090951969d79d85725dfe78280537cd1d0707be4 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/transports/appendfile.c,v 1.14 2006/03/01 11:24:04 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/appendfile.c,v 1.15 2006/04/20 14:11:29 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -1333,10 +1333,15 @@ if (path[0] != '/')
   return FALSE;
   }
 
-/* For a file delivery, make sure the local part in the address is updated to
-the true local part. */
+/* For a file delivery, make sure the local part in the address(es) is updated
+to the true local part. */
 
-if (testflag(addr, af_file)) addr->local_part = string_copy(path);
+if (testflag(addr, af_file))
+  {
+  address_item *addr2;
+  for (addr2 = addr; addr2 != NULL; addr2 = addr2->next)
+    addr2->local_part = string_copy(path);
+  }
 
 /* The available mailbox formats depend on whether it is a directory or a file
 delivery. */
diff --git a/test/confs/0534 b/test/confs/0534
new file mode 100644 (file)
index 0000000..5e83476
--- /dev/null
@@ -0,0 +1,50 @@
+# Exim test configuration 0534
+
+exim_path = EXIM_PATH
+host_lookup_order = bydns
+primary_hostname = myhost.test.ex
+rfc1413_query_timeout = 0s
+spool_directory = DIR/spool
+log_file_path = DIR/spool/log/%slog
+gecos_pattern = ""
+gecos_name = CALLER_NAME
+
+# ----- Main settings -----
+
+
+
+# ----- Routers -----
+
+begin routers
+
+r1:
+  driver = redirect
+  local_part_prefix = file-
+  local_part_suffix = =*
+  data = DIR/test-mail/${substr_1:$local_part_suffix}
+  file_transport = t1
+
+r2:
+  driver = redirect
+  local_part_prefix = pipe-
+  local_part_suffix = =*
+  data = |${substr_1:$local_part_suffix}
+  pipe_transport = t2
+
+
+# ----- Transports -----
+
+begin transports
+
+t1:
+  driver = appendfile
+  envelope_to_add
+  user = CALLER
+  batch_max = 10
+
+t2:
+  driver = pipe
+  user = CALLER
+  batch_max = 10
+
+# End
index 70c8c88387264c0590eb4c68d201565331e6cd4b..8cf2f6097596712f2d68f026fd22876de6533481 100644 (file)
@@ -3,7 +3,7 @@
 1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
 1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss
 1999-03-02 09:44:33 10HmaY-0005vi-00 => TESTSUITE/test-mail/afolder <t12@test.ex> R=r1 T=t1
-1999-03-02 09:44:33 10HmaY-0005vi-00 => TESTSUITE/test-mail/afolder <t11@test.ex> R=r1 T=t1
+1999-03-02 09:44:33 10HmaY-0005vi-00 -> TESTSUITE/test-mail/afolder <t11@test.ex> R=r1 T=t1
 1999-03-02 09:44:33 10HmaY-0005vi-00 Completed
 1999-03-02 09:44:33 10HmaZ-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss
 1999-03-02 09:44:33 10HmaZ-0005vi-00 == save bfolder <t2@test.ex> R=r2 T=t2 defer (-21): appendfile: file or directory name "bfolder" is not absolute
diff --git a/test/log/0534 b/test/log/0534
new file mode 100644 (file)
index 0000000..c59e48e
--- /dev/null
@@ -0,0 +1,9 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local S=sss
+1999-03-02 09:44:33 10HmaX-0005vi-00 => |TESTSUITE/bin/../bin/iefbr14 <pipe-userz=TESTSUITE/bin/../bin/iefbr14@test.ex> R=r2 T=t2
+1999-03-02 09:44:33 10HmaX-0005vi-00 => |TESTSUITE/bin/iefbr14 <pipe-usery=TESTSUITE/bin/iefbr14@test.ex> R=r2 T=t2
+1999-03-02 09:44:33 10HmaX-0005vi-00 -> |TESTSUITE/bin/iefbr14 <pipe-userx=TESTSUITE/bin/iefbr14@test.ex> R=r2 T=t2
+1999-03-02 09:44:33 10HmaX-0005vi-00 => TESTSUITE/test-mail/mbox2 <file-usera=mbox2@test.ex> R=r1 T=t1
+1999-03-02 09:44:33 10HmaX-0005vi-00 -> TESTSUITE/test-mail/mbox2 <file-userz=mbox2@test.ex> R=r1 T=t1
+1999-03-02 09:44:33 10HmaX-0005vi-00 => TESTSUITE/test-mail/mbox <file-usery=mbox@test.ex> R=r1 T=t1
+1999-03-02 09:44:33 10HmaX-0005vi-00 -> TESTSUITE/test-mail/mbox <file-userx=mbox@test.ex> R=r1 T=t1
+1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
index 3810e11965b381b514b54c8a2f473bc3aaf9d176..96b94a18981503d01b9d574599d9ed5c50cb3819 100644 (file)
@@ -17,12 +17,3 @@ From: CALLER_NAME <CALLER@test.ex>
 Date: Tue, 2 Mar 1999 09:44:33 +0000
 
 
-From CALLER@test.ex Tue Mar 02 09:44:33 1999
-Received: from CALLER by mail.test.ex with local (Exim x.yz)
-       (envelope-from <CALLER@test.ex>)
-       id 10HmaY-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000
-Message-Id: <E10HmaY-0005vi-00@mail.test.ex>
-From: CALLER_NAME <CALLER@test.ex>
-Date: Tue, 2 Mar 1999 09:44:33 +0000
-
-
diff --git a/test/mail/0534.mbox b/test/mail/0534.mbox
new file mode 100644 (file)
index 0000000..26716f5
--- /dev/null
@@ -0,0 +1,12 @@
+From CALLER@myhost.test.ex Tue Mar 02 09:44:33 1999
+Envelope-to: file-usery=mbox@test.ex,
+ file-userx=mbox@test.ex
+Received: from CALLER by myhost.test.ex with local (Exim x.yz)
+       (envelope-from <CALLER@myhost.test.ex>)
+       id 10HmaX-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000
+Message-Id: <E10HmaX-0005vi-00@myhost.test.ex>
+From: CALLER_NAME <CALLER@myhost.test.ex>
+Date: Tue, 2 Mar 1999 09:44:33 +0000
+
+A test message.
+
diff --git a/test/mail/0534.mbox2 b/test/mail/0534.mbox2
new file mode 100644 (file)
index 0000000..4d2c754
--- /dev/null
@@ -0,0 +1,12 @@
+From CALLER@myhost.test.ex Tue Mar 02 09:44:33 1999
+Envelope-to: file-usera=mbox2@test.ex,
+ file-userz=mbox2@test.ex
+Received: from CALLER by myhost.test.ex with local (Exim x.yz)
+       (envelope-from <CALLER@myhost.test.ex>)
+       id 10HmaX-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000
+Message-Id: <E10HmaX-0005vi-00@myhost.test.ex>
+From: CALLER_NAME <CALLER@myhost.test.ex>
+Date: Tue, 2 Mar 1999 09:44:33 +0000
+
+A test message.
+
index 76cc4b99b967b7d79b86eeff9aed3f211f64c01c..2e0c724175ce277d53de8e20e620ba75f88d18d7 100755 (executable)
@@ -1,6 +1,6 @@
 #! /usr/bin/perl -w
 
-# $Cambridge: exim/test/runtest,v 1.6 2006/03/17 16:51:45 ph10 Exp $
+# $Cambridge: exim/test/runtest,v 1.7 2006/04/20 14:11:29 ph10 Exp $
 
 ###############################################################################
 # This is the controlling script for the "new" test suite for Exim. It should #
@@ -23,7 +23,7 @@ use Socket;
 
 # Start by initializing some global variables
 
-$testversion = "4.61 (06-Feb-06)";
+$testversion = "4.62 (20-Apr-06)";
 
 $cf = "bin/cf";
 $cr = "\r";
index 7bd1ff9d4c6c11760a2d4a631059f6583f6f18e4..012d4e3e6377ca2e24271b728e13a9d626c2f3d6 100644 (file)
@@ -1,7 +1,7 @@
 # use of file= in appendfile with filter setting the folder
 exim -odi t1
 ****
-# Batched multiple deliveries (it doesn't batch)
+# Batched multiple deliveries (since 4.62 it does batch)
 exim -odi t11 t12
 ****
 # Error message for failure before full path is set
diff --git a/test/scripts/0000-Basic/0534 b/test/scripts/0000-Basic/0534
new file mode 100644 (file)
index 0000000..0e03960
--- /dev/null
@@ -0,0 +1,10 @@
+# Batch_max when redirecting to a mailbox or a pipe
+exim -odi file-userx=mbox@test.ex \
+          file-usery=mbox@test.ex \
+          file-userz=mbox2@test.ex \
+          file-usera=mbox2@test.ex \
+          pipe-userx=DIR/bin/iefbr14@test.ex \
+          pipe-usery=DIR/bin/iefbr14@test.ex \
+          pipe-userz=DIR/bin/../bin/iefbr14@test.ex  
+A test message.
+****