From 94ecf089d68ac5b85c2a99177a8e4b4d35d5aa2e Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 20 Dec 2020 15:49:39 +0000 Subject: [PATCH] Fix local delivery delay when combined with remote callout/hold. Bug 2599 --- doc/doc-docbook/spec.xfpt | 4 +- doc/doc-txt/ChangeLog | 3 + src/src/deliver.c | 16 ++- test/confs/0580 | 28 +++-- test/log/0580 | 18 ++-- test/log/0581 | 16 +-- test/log/0582 | 2 +- test/mail/0580.local | 10 ++ test/scripts/0000-Basic/0580 | 40 ++++++-- test/scripts/0000-Basic/0582 | 7 +- test/stdout/0580 | 191 +++++++++++++++++++++++++++++++++++ 11 files changed, 296 insertions(+), 39 deletions(-) create mode 100644 test/mail/0580.local create mode 100644 test/stdout/0580 diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt index 302a62312..2938de576 100644 --- a/doc/doc-docbook/spec.xfpt +++ b/doc/doc-docbook/spec.xfpt @@ -3885,7 +3885,9 @@ id, and the remaining ones must be email addresses. However, if the message is active (in the middle of a delivery attempt), it is not altered. This option can be used only by an admin user. -.vitem "&%-MC%&&~<&'transport'&>&~<&'hostname'&>&~<&'sequence&~number'&>&&& +.vitem "&%-MC%&&~<&'transport'&>&~<&'hostname'&>&&& + &~<&'host&~IP'&>&&& + &~<&'sequence&~number'&>&&& &~<&'message&~id'&>" .oindex "&%-MC%&" .cindex "SMTP" "passed connection" diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index f2d34e84d..396ec3362 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -156,6 +156,9 @@ JH/31 The ESMTP option name advertised for the SUPPORT_EARLY_PIPE build option Changeover between the implementations is handled by the mechanisms alrready coded. +JH/32 Bug 2599: fix delay of delivery to a local address where there is also + a remote which uses callout/hold. Previously the local was queued. + Exim version 4.94 ----------------- diff --git a/src/src/deliver.c b/src/src/deliver.c index 4e6f08f89..ec5990cc1 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -7067,13 +7067,23 @@ if ( mua_wrapper /* If this is a run to continue deliveries to an external channel that is -already set up, defer any local deliveries. */ +already set up, defer any local deliveries. -if (continue_transport) +jgh 2020/12/20: I don't see why; locals should be quick. +The defer goes back to version 1.62 in 1997. A local being still deliverable +during a continued run might result from something like a defer during the +original delivery, eg. in a DB lookup. Unlikely but possible. + +To avoid delaying a local when combined with a callout-hold for a remote +delivery, test continue_sequence rather than continue_transport. */ + +if (continue_sequence > 1 && addr_local) { + DEBUG(D_deliver|D_retry|D_route) + debug_printf("deferring local deliveries due to continued-transport\n"); if (addr_defer) { - address_item *addr = addr_defer; + address_item * addr = addr_defer; while (addr->next) addr = addr->next; addr->next = addr_local; } diff --git a/test/confs/0580 b/test/confs/0580 index 6dbc06d64..a96b01162 100644 --- a/test/confs/0580 +++ b/test/confs/0580 @@ -18,28 +18,44 @@ OPT begin acl check_rcpt: - accept verify = recipient/callout=use_sender,hold + accept + local_parts = delay : remote + verify = recipient/callout=2s,use_sender,defer_ok,hold + accept + local_parts = local + + accept + verify = recipient/callout=use_sender,hold # ----- Routers ----- begin routers -r1: - driver = manualroute +r_local: + driver = accept + local_parts = local + transport = local_deliv + +r_remote: + driver = manualroute route_list = * 127.0.0.1 - self = send - transport = t1 + self = send + transport = t1 begin transports +local_deliv: + driver = appendfile + file = DIR/test-mail/$local_part_data + user = CALLER + t1: driver = smtp port = PORT_S hosts_try_fastopen = : - # ----- Retry ----- begin retry diff --git a/test/log/0580 b/test/log/0580 index f006778e5..e748c69e1 100644 --- a/test/log/0580 +++ b/test/log/0580 @@ -1,15 +1,19 @@ 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss for usery@test.ex -1999-03-02 09:44:33 10HmaX-0005vi-00 => usery@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmaX-0005vi-00 => usery@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" 1999-03-02 09:44:33 10HmaX-0005vi-00 Completed 1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss for usery@test.ex usery2@test.ex -1999-03-02 09:44:33 10HmaY-0005vi-00 => usery@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" -1999-03-02 09:44:33 10HmaY-0005vi-00 -> usery2@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmaY-0005vi-00 => usery@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmaY-0005vi-00 -> usery2@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" 1999-03-02 09:44:33 10HmaY-0005vi-00 Completed 1999-03-02 09:44:33 10HmaZ-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss for usery3@test.ex usery@test.ex -1999-03-02 09:44:33 10HmaZ-0005vi-00 => usery3@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" -1999-03-02 09:44:33 10HmaZ-0005vi-00 -> usery@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmaZ-0005vi-00 => usery3@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmaZ-0005vi-00 -> usery@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" 1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed 1999-03-02 09:44:33 10HmbA-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss for usery4@test.ex usery5@test.ex -1999-03-02 09:44:33 10HmbA-0005vi-00 => usery4@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" -1999-03-02 09:44:33 10HmbA-0005vi-00 -> usery5@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmbA-0005vi-00 => usery4@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmbA-0005vi-00 -> usery5@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" 1999-03-02 09:44:33 10HmbA-0005vi-00 Completed +1999-03-02 09:44:33 10HmbB-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss for remote@test.ex local@test.ex +1999-03-02 09:44:33 10HmbB-0005vi-00 => local R=r_local T=local_deliv +1999-03-02 09:44:33 10HmbB-0005vi-00 => remote@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 message accepted" +1999-03-02 09:44:33 10HmbB-0005vi-00 Completed diff --git a/test/log/0581 b/test/log/0581 index 14f8d48a2..2a82ace48 100644 --- a/test/log/0581 +++ b/test/log/0581 @@ -6,22 +6,22 @@ ******** SERVER ******** 1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port PORT_D 1999-03-02 09:44:33 10HmaX-0005vi-00 <= userc@ok.example H=(test.ex) [127.0.0.1] P=esmtp S=sss for userd@test.ex -1999-03-02 09:44:33 10HmaX-0005vi-00 => userd@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmaX-0005vi-00 => userd@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" 1999-03-02 09:44:33 10HmaX-0005vi-00 Completed 1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port PORT_D 1999-03-02 09:44:33 10HmaY-0005vi-00 <= usere@ok.example H=(test.ex) [127.0.0.1] P=esmtp S=sss for userf@test.ex -1999-03-02 09:44:33 10HmaY-0005vi-00 => userf@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmaY-0005vi-00 => userf@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" 1999-03-02 09:44:33 10HmaY-0005vi-00 Completed 1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port PORT_D 1999-03-02 09:44:33 10HmaZ-0005vi-00 <= userc@ok.example H=(test.ex) [127.0.0.1] P=esmtp S=sss for userd@test.ex userd2@test.ex -1999-03-02 09:44:33 10HmaZ-0005vi-00 => userd@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" -1999-03-02 09:44:33 10HmaZ-0005vi-00 -> userd2@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmaZ-0005vi-00 => userd@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmaZ-0005vi-00 -> userd2@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" 1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed 1999-03-02 09:44:33 10HmbA-0005vi-00 <= userc@ok.example H=(test.ex) [127.0.0.1] P=esmtp S=sss for userd3@test.ex userd2@test.ex -1999-03-02 09:44:33 10HmbA-0005vi-00 => userd3@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" -1999-03-02 09:44:33 10HmbA-0005vi-00 -> userd2@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmbA-0005vi-00 => userd3@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmbA-0005vi-00 -> userd2@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" 1999-03-02 09:44:33 10HmbA-0005vi-00 Completed 1999-03-02 09:44:33 10HmbB-0005vi-00 <= userc@ok.example H=(test.ex) [127.0.0.1] P=esmtp S=sss for userd4@test.ex userd5@test.ex -1999-03-02 09:44:33 10HmbB-0005vi-00 => userd4@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" -1999-03-02 09:44:33 10HmbB-0005vi-00 -> userd5@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmbB-0005vi-00 => userd4@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" +1999-03-02 09:44:33 10HmbB-0005vi-00 -> userd5@test.ex R=r_remote T=t1 H=127.0.0.1 [127.0.0.1] C="250 yeah got that message" 1999-03-02 09:44:33 10HmbB-0005vi-00 Completed diff --git a/test/log/0582 b/test/log/0582 index fd431813f..179e80fea 100644 --- a/test/log/0582 +++ b/test/log/0582 @@ -1,4 +1,4 @@ 1999-03-02 09:44:33 U=CALLER F= temporarily rejected RCPT : Could not complete recipient verify callout: 127.0.0.1 [127.0.0.1] : SMTP error from remote mail server after RCPT TO:: 451 not right now 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss for userh@test.ex 1999-03-02 09:44:33 10HmaX-0005vi-00 H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after end of data: 451 not right now -1999-03-02 09:44:33 10HmaX-0005vi-00 == userh@test.ex R=r1 T=t1 defer (-46) H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after end of data: 451 not right now +1999-03-02 09:44:33 10HmaX-0005vi-00 == userh@test.ex R=r_remote T=t1 defer (-46) H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after end of data: 451 not right now diff --git a/test/mail/0580.local b/test/mail/0580.local new file mode 100644 index 000000000..5ee7d9dd9 --- /dev/null +++ b/test/mail/0580.local @@ -0,0 +1,10 @@ +From CALLER@myhost.test.ex Tue Mar 02 09:44:33 1999 +Received: from CALLER by myhost.test.ex with local-smtp (Exim x.yz) + (envelope-from ) + id 10HmbB-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Subject: test +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + + diff --git a/test/scripts/0000-Basic/0580 b/test/scripts/0000-Basic/0580 index 8d8a11751..5cce3e858 100644 --- a/test/scripts/0000-Basic/0580 +++ b/test/scripts/0000-Basic/0580 @@ -19,7 +19,7 @@ QUIT 221 Bye **** # -exim -bs +exim -bs -odi mail from: rcpt to: data @@ -29,7 +29,6 @@ body . quit **** -sleep 1 # # # multiple recipients @@ -62,7 +61,7 @@ QUIT 221 Bye **** # -exim -bs +exim -bs -odi mail from: rcpt to: rcpt to: @@ -73,7 +72,6 @@ body . quit **** -sleep 1 # # # 2nd callout result is cached (above); should not activate LCC @@ -105,7 +103,7 @@ QUIT 221 Bye **** # -exim -bs +exim -bs -odi mail from: rcpt to: rcpt to: @@ -116,7 +114,6 @@ body . quit **** -sleep 1 # # # no cache hits; should do LCC @@ -138,7 +135,7 @@ QUIT 221 Bye **** # -exim -bs +exim -bs -odi mail from: rcpt to: rcpt to: @@ -149,8 +146,33 @@ body . quit **** -sleep 1 # +# cmdline -bs send, rmt conn timeout, also local rcpt +server PORT_S +220 Welcome +EHLO +250 Hi +MAIL FROM +250 OK +RCPT TO +250 OK +DATA +354 hit me +. +250 message accepted +QUIT +221 bye +**** +exim -bs -odi +mail from: +rcpt to: +rcpt to: +data +Subject: test +. +quit +**** +exim -bp +**** # -no_stdout_check no_msglog_check diff --git a/test/scripts/0000-Basic/0582 b/test/scripts/0000-Basic/0582 index 3eefcc979..6da20235a 100644 --- a/test/scripts/0000-Basic/0582 +++ b/test/scripts/0000-Basic/0582 @@ -15,12 +15,11 @@ QUIT 221 Bye **** # -exim -bs +exim -bs -odi mail from: rcpt to: quit **** -sleep 1 # # cmdline -bs send, data-time defer server PORT_S @@ -39,7 +38,7 @@ QUIT 221 Bye **** # -exim -bs +exim -bs -odi mail from: rcpt to: data @@ -49,7 +48,7 @@ body . quit **** -sleep 1 +# # # no_stdout_check diff --git a/test/stdout/0580 b/test/stdout/0580 new file mode 100644 index 000000000..7dbc7d2cf --- /dev/null +++ b/test/stdout/0580 @@ -0,0 +1,191 @@ +220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 OK +250 Accepted +354 Enter message, ending with "." on a line by itself +250 OK id=10HmaX-0005vi-00 +221 myhost.test.ex closing connection +220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 OK +250 Accepted +250 Accepted +354 Enter message, ending with "." on a line by itself +250 OK id=10HmaY-0005vi-00 +221 myhost.test.ex closing connection +220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 OK +250 Accepted +250 Accepted +354 Enter message, ending with "." on a line by itself +250 OK id=10HmaZ-0005vi-00 +221 myhost.test.ex closing connection +220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 OK +250 Accepted +250 Accepted +354 Enter message, ending with "." on a line by itself +250 OK id=10HmbA-0005vi-00 +221 myhost.test.ex closing connection +220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 OK +250 Accepted +250 Accepted +354 Enter message, ending with "." on a line by itself +250 OK id=10HmbB-0005vi-00 +221 myhost.test.ex closing connection + +******** SERVER ******** +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Welcome +EHLO myhost.test.ex +250 Hi +MAIL FROM: +250 OK +RCPT TO: +250 OK +DATA +354 hit me +Received: from CALLER by myhost.test.ex with local-smtp (Exim x.yz) + (envelope-from ) + id 10HmaX-0005vi-00 + for usery@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +Subject: test +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +body +. +250 yeah got that message +QUIT +221 Bye +End of script +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Welcome +EHLO myhost.test.ex +250 Hi +MAIL FROM: +250 OK +RCPT TO: +250 OK +QUIT +221 Bye +Expected EOF read from client +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Welcome +EHLO myhost.test.ex +250 Hi +MAIL FROM: +250 OK +RCPT TO: +250 OK +RCPT TO: +250 OK +DATA +354 hit me +Received: from CALLER by myhost.test.ex with local-smtp (Exim x.yz) + (envelope-from ) + id 10HmaY-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Subject: test +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +body +. +250 yeah got that message +QUIT +221 Bye +End of script +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Welcome +EHLO myhost.test.ex +250 Hi +MAIL FROM: +250 OK +RCPT TO: +250 OK +QUIT +221 Bye +Expected EOF read from client +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Welcome +EHLO myhost.test.ex +250 Hi +MAIL FROM: +250 OK +RCPT TO: +250 OK +RCPT TO: +250 OK +DATA +354 hit me +Received: from CALLER by myhost.test.ex with local-smtp (Exim x.yz) + (envelope-from ) + id 10HmaZ-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Subject: test +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +body +. +250 yeah got that message +QUIT +221 Bye +End of script +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Welcome +EHLO myhost.test.ex +250 Hi +MAIL FROM: +250 OK +RCPT TO: +250 OK +RCPT TO: +250 OK +DATA +354 hit me +Received: from CALLER by myhost.test.ex with local-smtp (Exim x.yz) + (envelope-from ) + id 10HmbA-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Subject: test +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +body +. +250 yeah got that message +QUIT +221 Bye +End of script +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Welcome +EHLO myhost.test.ex +250 Hi +MAIL FROM: +250 OK +RCPT TO: +250 OK +DATA +354 hit me +Received: from CALLER by myhost.test.ex with local-smtp (Exim x.yz) + (envelope-from ) + id 10HmbB-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Subject: test +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +. +250 message accepted +QUIT +221 bye +End of script -- 2.30.2