From f7fd3850601c141d3a8d5b9cc6e6403f623923ae Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Thu, 20 Apr 2006 14:11:29 +0000 Subject: [PATCH] Make batch delivery work for files and pipes set up by redirection. --- doc/doc-txt/ChangeLog | 7 ++++- doc/doc-txt/NewStuff | 6 +++- src/src/deliver.c | 25 ++++++++++++----- src/src/transports/appendfile.c | 13 ++++++--- test/confs/0534 | 50 +++++++++++++++++++++++++++++++++ test/log/0411 | 2 +- test/log/0534 | 9 ++++++ test/mail/0411.afolder | 9 ------ test/mail/0534.mbox | 12 ++++++++ test/mail/0534.mbox2 | 12 ++++++++ test/runtest | 4 +-- test/scripts/0000-Basic/0411 | 2 +- test/scripts/0000-Basic/0534 | 10 +++++++ 13 files changed, 135 insertions(+), 26 deletions(-) create mode 100644 test/confs/0534 create mode 100644 test/log/0534 create mode 100644 test/mail/0534.mbox create mode 100644 test/mail/0534.mbox2 create mode 100644 test/scripts/0000-Basic/0534 diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index f51f97071..8fb90d750 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -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 ----------------- diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index 38c20991b..dc03699f3 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -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 ------------ diff --git a/src/src/deliver.c b/src/src/deliver.c index 0cb0132c4..a80d97842 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -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) && diff --git a/src/src/transports/appendfile.c b/src/src/transports/appendfile.c index 7a415de7a..090951969 100644 --- a/src/src/transports/appendfile.c +++ b/src/src/transports/appendfile.c @@ -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 index 000000000..5e83476fb --- /dev/null +++ b/test/confs/0534 @@ -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 diff --git a/test/log/0411 b/test/log/0411 index 70c8c8838..8cf2f6097 100644 --- a/test/log/0411 +++ b/test/log/0411 @@ -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 R=r1 T=t1 -1999-03-02 09:44:33 10HmaY-0005vi-00 => TESTSUITE/test-mail/afolder R=r1 T=t1 +1999-03-02 09:44:33 10HmaY-0005vi-00 -> TESTSUITE/test-mail/afolder 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 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 index 000000000..c59e48e5c --- /dev/null +++ b/test/log/0534 @@ -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 R=r2 T=t2 +1999-03-02 09:44:33 10HmaX-0005vi-00 => |TESTSUITE/bin/iefbr14 R=r2 T=t2 +1999-03-02 09:44:33 10HmaX-0005vi-00 -> |TESTSUITE/bin/iefbr14 R=r2 T=t2 +1999-03-02 09:44:33 10HmaX-0005vi-00 => TESTSUITE/test-mail/mbox2 R=r1 T=t1 +1999-03-02 09:44:33 10HmaX-0005vi-00 -> TESTSUITE/test-mail/mbox2 R=r1 T=t1 +1999-03-02 09:44:33 10HmaX-0005vi-00 => TESTSUITE/test-mail/mbox R=r1 T=t1 +1999-03-02 09:44:33 10HmaX-0005vi-00 -> TESTSUITE/test-mail/mbox R=r1 T=t1 +1999-03-02 09:44:33 10HmaX-0005vi-00 Completed diff --git a/test/mail/0411.afolder b/test/mail/0411.afolder index 3810e1196..96b94a189 100644 --- a/test/mail/0411.afolder +++ b/test/mail/0411.afolder @@ -17,12 +17,3 @@ From: CALLER_NAME 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 ) - id 10HmaY-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 -Message-Id: -From: CALLER_NAME -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 index 000000000..26716f507 --- /dev/null +++ b/test/mail/0534.mbox @@ -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 ) + id 10HmaX-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +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 index 000000000..4d2c7548b --- /dev/null +++ b/test/mail/0534.mbox2 @@ -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 ) + id 10HmaX-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +A test message. + diff --git a/test/runtest b/test/runtest index 76cc4b99b..2e0c72417 100755 --- a/test/runtest +++ b/test/runtest @@ -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"; diff --git a/test/scripts/0000-Basic/0411 b/test/scripts/0000-Basic/0411 index 7bd1ff9d4..012d4e3e6 100644 --- a/test/scripts/0000-Basic/0411 +++ b/test/scripts/0000-Basic/0411 @@ -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 index 000000000..0e039601c --- /dev/null +++ b/test/scripts/0000-Basic/0534 @@ -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. +**** -- 2.30.2