[exim-cvs] Events: add msg:defer Bug 2477

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Exim Git Commits Mailing List
Ημερομηνία:  
Προς: exim-cvs
Αντικείμενο: [exim-cvs] Events: add msg:defer Bug 2477
Gitweb: https://git.exim.org/exim.git/commitdiff/78598e6a6a8cda8d1b50685188682749929df614
Commit:     78598e6a6a8cda8d1b50685188682749929df614
Parent:     de41aff0511cad420dd1936b23dce61e04ce6ab4
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sat Dec 14 23:01:03 2019 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sun Dec 15 13:28:47 2019 +0000


    Events: add msg:defer  Bug 2477
---
 doc/doc-docbook/spec.xfpt       |  8 ++++++--
 doc/doc-txt/NewStuff            |  2 ++
 src/src/transports/smtp.c       | 18 +++++++++++++-----
 test/aux-fixed/event-logger-acl |  4 ++++
 test/runtest                    |  2 +-
 test/scripts/5700-events/5700   | 22 ++++++++++++++++++++++
 6 files changed, 48 insertions(+), 8 deletions(-)


diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt
index a92ac91..55ab7f2 100644
--- a/doc/doc-docbook/spec.xfpt
+++ b/doc/doc-docbook/spec.xfpt
@@ -41059,14 +41059,17 @@ Events have names which correspond to the point in process at which they fire.
The name is placed in the variable &$event_name$& and the event action
expansion must check this, as it will be called for every possible event type.

+.new
 The current list of events is:
+.wen
 .display
 &`dane:fail              after    transport  `& per connection
 &`msg:complete           after    main       `& per message
+&`msg:defer              after    transport  `& per message per delivery try
 &`msg:delivery           after    transport  `& per recipient
 &`msg:rcpt:host:defer    after    transport  `& per recipient per host
 &`msg:rcpt:defer         after    transport  `& per recipient
-&`msg:host:defer         after    transport  `& per attempt
+&`msg:host:defer         after    transport  `& per host per delivery try; host errors
 &`msg:fail:delivery      after    transport  `& per recipient
 &`msg:fail:internal      after    main       `& per recipient
 &`tcp:connect            before   transport  `& per connection
@@ -41092,12 +41095,13 @@ An additional variable, &$event_data$&, is filled with information varying
 with the event type:
 .display
 &`dane:fail            `& failure reason
+&`msg:defer            `& error string
 &`msg:delivery         `& smtp confirmation message
 &`msg:fail:internal    `& failure reason
 &`msg:fail:delivery    `& smtp error message
+&`msg:host:defer       `& error string
 &`msg:rcpt:host:defer  `& error string
 &`msg:rcpt:defer       `& error string
-&`msg:host:defer       `& error string
 &`tls:cert             `& verification chain depth
 &`smtp:connect         `& smtp banner
 &`smtp:ehlo            `& smtp ehlo response
diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff
index 763a806..cd380a3 100644
--- a/doc/doc-txt/NewStuff
+++ b/doc/doc-txt/NewStuff
@@ -15,6 +15,8 @@ Version 4.94
  2. Channel-binding for authenticators is now supported under OpenSSL.
     Previously it was GnuTLS-only.


+ 3. A msg:defer event.
+

 Version 4.93
 ------------
diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c
index 99b793b..92723a2 100644
--- a/src/src/transports/smtp.c
+++ b/src/src/transports/smtp.c
@@ -766,12 +766,13 @@ deliver_msglog("%s H=%s [%s] %s\n", tod_stamp(tod_log),
 Arguments:
   addr                  the address item containing error information
   host                  the current host
+  evstr            the event


Returns: nothing
*/

static void
-deferred_event_raise(address_item *addr, host_item *host)
+deferred_event_raise(address_item * addr, host_item * host, uschar * evstr)
{
uschar * action = addr->transport->event_action;
const uschar * save_domain;
@@ -793,7 +794,7 @@ transport_name = addr->transport->name;
deliver_domain = addr->domain;
deliver_localpart = addr->local_part;

-(void) event_raise(action, US"msg:host:defer",
+(void) event_raise(action, evstr,
     addr->message
       ? addr->basic_errno > 0
     ? string_sprintf("%s: %s", addr->message, strerror(addr->basic_errno))
@@ -5150,7 +5151,7 @@ retry_non_continued:


 #ifndef DISABLE_EVENT
       if (rc == DEFER)
-        deferred_event_raise(first_addr, host);
+    deferred_event_raise(first_addr, host, US"msg:host:defer");
 #endif


       /* If STARTTLS was accepted, but there was a failure in setting up the
@@ -5178,11 +5179,18 @@ retry_non_continued:
         if (rc == DEFER && first_addr->basic_errno != ERRNO_AUTHFAIL)
           write_logs(host, first_addr->message, first_addr->basic_errno);
 # ifndef DISABLE_EVENT
-        if (rc == DEFER)
-          deferred_event_raise(first_addr, host);
+    if (rc == DEFER)
+      deferred_event_raise(first_addr, host, US"msg:host:defer");
 # endif
         }
 #endif    /*DISABLE_TLS*/
+
+#ifndef DISABLE_EVENT
+      /* If the last host gave a defer raise a per-message event */
+
+      if (!nexthost && (message_defer || rc == DEFER))
+    deferred_event_raise(first_addr, host, US"msg:defer");
+#endif
       }


     /* Delivery attempt finished */
diff --git a/test/aux-fixed/event-logger-acl b/test/aux-fixed/event-logger-acl
index 980d47f..1532172 100644
--- a/test/aux-fixed/event-logger-acl
+++ b/test/aux-fixed/event-logger-acl
@@ -54,6 +54,10 @@ ev_msg:
     accept condition = ${if eq {$event_name}{msg:delivery}}
        acl = ev_msg_log delivery "confirmation <$event_data>"


+    accept condition = ${if eq {$event_name}{msg:defer}}
+       acl = ev_msg_log "message deferral" \
+            "errno <$event_defer_errno> errstr <$event_data>"
+
     accept condition = ${if eq {$event_name}{msg:host:defer}}
        acl = ev_msg_log "host deferral" \
             "errno <$event_defer_errno> errstr <$event_data>"
diff --git a/test/runtest b/test/runtest
index d678abd..14601c6 100755
--- a/test/runtest
+++ b/test/runtest
@@ -1830,7 +1830,7 @@ $munges =
     },


     'timeout_errno' =>        # actual errno differs Solaris vs. Linux
-    { 'mainlog' => 's/(host deferral .* errno) <\d+> /$1 <EEE> /' },
+    { 'mainlog' => 's/((?:host|message) deferral .* errno) <\d+> /$1 <EEE> /' },


     'peer_terminated_conn' =>    # actual error differs FreedBSD vs. Linux
     { 'stderr' => 's/^(  SMTP\()Connection reset by peer(\)<<)$/$1closed$2/' },
diff --git a/test/scripts/5700-events/5700 b/test/scripts/5700-events/5700
index 89b0c5c..c6b6e76 100644
--- a/test/scripts/5700-events/5700
+++ b/test/scripts/5700-events/5700
@@ -102,6 +102,28 @@ QUIT
 ****
 exim -qqf
 ****
+exim -odq userx@domain1
+A message which will get deferred after data
+****
+server PORT_S
+220 ESMTP
+EHLO
+250-OK
+250 HELP
+MAIL
+250 OK
+RCPT
+250 OK
+DATA
+354
+.
+450 post-data problem
+QUIT
+220 OK
+****
+exim -qqf
+****
+#
 #
 #
 #