process timeouts like normal errors, so that they will get delivered to
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 4 Jan 1983 05:02:01 +0000 (21:02 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 4 Jan 1983 05:02:01 +0000 (21:02 -0800)
the correct address (i.e., the Errors-To: address)

SCCS-vsn: usr.sbin/sendmail/src/deliver.c 3.139
SCCS-vsn: usr.sbin/sendmail/src/queue.c 3.63
SCCS-vsn: usr.sbin/sendmail/src/envelope.c 3.5

usr/src/usr.sbin/sendmail/src/deliver.c
usr/src/usr.sbin/sendmail/src/envelope.c
usr/src/usr.sbin/sendmail/src/queue.c

index cee4fe3..bf22c55 100644 (file)
@@ -3,7 +3,7 @@
 # include "sendmail.h"
 # include <sys/stat.h>
 
 # include "sendmail.h"
 # include <sys/stat.h>
 
-SCCSID(@(#)deliver.c   3.138           %G%);
+SCCSID(@(#)deliver.c   3.139           %G%);
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
@@ -360,10 +360,7 @@ deliver(e, firstto)
                                i = smtprcpt(to);
                                if (i != EX_OK)
                                {
                                i = smtprcpt(to);
                                if (i != EX_OK)
                                {
-                                       if (i == EX_TEMPFAIL)
-                                               to->q_flags |= QQUEUEUP;
-                                       else
-                                               to->q_flags |= QBADADDR;
+                                       markfailure(e, to, i);
                                        giveresponse(i, m);
                                }
                                else
                                        giveresponse(i, m);
                                }
                                else
@@ -402,12 +399,7 @@ deliver(e, firstto)
        if (rcode != EX_OK)
        {
                for (to = tochain; to != NULL; to = to->q_tchain)
        if (rcode != EX_OK)
        {
                for (to = tochain; to != NULL; to = to->q_tchain)
-               {
-                       if (rcode == EX_TEMPFAIL)
-                               to->q_flags |= QQUEUEUP;
-                       else
-                               to->q_flags |= QBADADDR;
-               }
+                       markfailure(e, to, rcode);
        }
 
        errno = 0;
        }
 
        errno = 0;
@@ -415,6 +407,45 @@ deliver(e, firstto)
        return (rcode);
 }
 \f/*
        return (rcode);
 }
 \f/*
+**  MARKFAILURE -- mark a failure on a specific address.
+**
+**     Parameters:
+**             e -- the envelope we are sending.
+**             q -- the address to mark.
+**             rcode -- the code signifying the particular failure.
+**
+**     Returns:
+**             none.
+**
+**     Side Effects:
+**             marks the address (and possibly the envelope) with the
+**                     failure so that an error will be returned or
+**                     the message will be queued, as appropriate.
+*/
+
+markfailure(e, q, rcode)
+       register ENVELOPE *e;
+       register ADDRESS *q;
+       int rcode;
+{
+       if (rcode == EX_OK)
+               return;
+       else if (rcode != EX_TEMPFAIL)
+               q->q_flags |= QBADADDR;
+       else if (curtime() > e->e_ctime + TimeOut)
+       {
+               extern char *pintvl();
+
+               if (!bitset(EF_TIMEOUT, e->e_flags))
+                       message(Arpa_Info, "Cannot send message for %s",
+                               pintvl(TimeOut, FALSE));
+               q->q_flags |= QBADADDR;
+               e->e_flags |= EF_TIMEOUT;
+       }
+       else
+               q->q_flags |= QQUEUEUP;
+}
+\f/*
 **  DOFORK -- do a fork, retrying a couple of times on failure.
 **
 **     This MUST be a macro, since after a vfork we are running
 **  DOFORK -- do a fork, retrying a couple of times on failure.
 **
 **     This MUST be a macro, since after a vfork we are running
index 65bdcf2..1648354 100644 (file)
@@ -3,7 +3,7 @@
 #include "sendmail.h"
 #include <sys/stat.h>
 
 #include "sendmail.h"
 #include <sys/stat.h>
 
-SCCSID(@(#)envelope.c  3.4             %G%);
+SCCSID(@(#)envelope.c  3.5             %G%);
 
 /*
 **  NEWENVELOPE -- allocate a new envelope
 
 /*
 **  NEWENVELOPE -- allocate a new envelope
@@ -114,18 +114,11 @@ dropenvelope(e)
                (void) returntosender("Return receipt", rlist, FALSE);
        }
 
                (void) returntosender("Return receipt", rlist, FALSE);
        }
 
-       /*
-       **  See if this message has timed out
-       */
-
-       if (bitset(EF_TIMEOUT, e->e_flags) && queueit)
-               timeout(e);
-
        /*
        **  Arrange to send error messages if there are fatal errors.
        */
 
        /*
        **  Arrange to send error messages if there are fatal errors.
        */
 
-       if (bitset(EF_FATALERRS, e->e_flags))
+       if (bitset(EF_FATALERRS|EF_TIMEOUT, e->e_flags))
                savemail(e);
 
        /*
                savemail(e);
 
        /*
index 3b945dd..00038e6 100644 (file)
@@ -5,10 +5,10 @@
 # include <errno.h>
 
 # ifndef QUEUE
 # include <errno.h>
 
 # ifndef QUEUE
-SCCSID(@(#)queue.c     3.62            %G%     (no queueing));
+SCCSID(@(#)queue.c     3.63            %G%     (no queueing));
 # else QUEUE
 
 # else QUEUE
 
-SCCSID(@(#)queue.c     3.62            %G%);
+SCCSID(@(#)queue.c     3.63            %G%);
 
 /*
 **  Work queue.
 
 /*
 **  Work queue.
@@ -467,7 +467,6 @@ dowork(w)
                (void) alarm(0);
                CurEnv->e_flags &= ~EF_FATALERRS;
                QueueRun = TRUE;
                (void) alarm(0);
                CurEnv->e_flags &= ~EF_FATALERRS;
                QueueRun = TRUE;
-               SendMode = SM_DELIVER;
                ErrorMode = EM_MAIL;
                CurEnv->e_id = &w->w_name[2];
 # ifdef LOG
                ErrorMode = EM_MAIL;
                CurEnv->e_id = &w->w_name[2];
 # ifdef LOG
@@ -503,15 +502,6 @@ dowork(w)
                if (!bitset(EF_FATALERRS, CurEnv->e_flags))
                        sendall(CurEnv, SM_DELIVER);
 
                if (!bitset(EF_FATALERRS, CurEnv->e_flags))
                        sendall(CurEnv, SM_DELIVER);
 
-               /* if still not sent, perhaps we should time out.... */
-# ifdef DEBUG
-               if (tTd(40, 3))
-                       printf("curtime=%ld, TimeOut=%ld\n", curtime(),
-                                            CurEnv->e_ctime + TimeOut);
-# endif DEBUG
-               if (curtime() > CurEnv->e_ctime + TimeOut)
-                       CurEnv->e_flags |= EF_TIMEOUT;
-
                /* finish up and exit */
                finis();
        }
                /* finish up and exit */
                finis();
        }
@@ -620,40 +610,6 @@ readqf(e, full)
        FileName = NULL;
 }
 \f/*
        FileName = NULL;
 }
 \f/*
-**  TIMEOUT -- process timeout on queue file.
-**
-**     Parameters:
-**             e -- the envelope that timed out.
-**
-**     Returns:
-**             none.
-**
-**     Side Effects:
-**             Returns a message to the sender saying that this
-**             message has timed out.
-*/
-
-timeout(e)
-       register ENVELOPE *e;
-{
-       char buf[MAXLINE];
-       extern char *pintvl();
-
-# ifdef DEBUG
-       if (tTd(40, 3))
-               printf("timeout(%s)\n", e->e_id);
-# endif DEBUG
-       e->e_to = NULL;
-       message(Arpa_Info, "Message has timed out");
-
-       /* return message to sender */
-       (void) sprintf(buf, "Cannot send mail for %s", pintvl(TimeOut, FALSE));
-       (void) returntosender(buf, &e->e_from, TRUE);
-
-       /* arrange to remove files from queue */
-       e->e_flags |= EF_CLRQUEUE;
-}
-\f/*
 **  PRINTQUEUE -- print out a representation of the mail queue
 **
 **     Parameters:
 **  PRINTQUEUE -- print out a representation of the mail queue
 **
 **     Parameters: