hooks for eventual better handling of SMTP recipients
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 31 Mar 1993 06:50:04 +0000 (22:50 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 31 Mar 1993 06:50:04 +0000 (22:50 -0800)
SCCS-vsn: usr.sbin/sendmail/src/recipient.c 6.33
SCCS-vsn: usr.sbin/sendmail/src/queue.c 6.40
SCCS-vsn: usr.sbin/sendmail/src/alias.c 6.29
SCCS-vsn: usr.sbin/sendmail/src/udb.c 6.16

usr/src/usr.sbin/sendmail/src/alias.c
usr/src/usr.sbin/sendmail/src/queue.c
usr/src/usr.sbin/sendmail/src/recipient.c
usr/src/usr.sbin/sendmail/src/udb.c

index d602604..dec9dde 100644 (file)
@@ -26,15 +26,15 @@ ERROR: DBM is no longer supported -- use NDBM instead.
 #ifndef lint
 #ifdef NEWDB
 #ifdef NDBM
 #ifndef lint
 #ifdef NEWDB
 #ifdef NDBM
-static char sccsid[] = "@(#)alias.c    6.28 (Berkeley) %G% (with NEWDB and NDBM)";
+static char sccsid[] = "@(#)alias.c    6.29 (Berkeley) %G% (with NEWDB and NDBM)";
 #else
 #else
-static char sccsid[] = "@(#)alias.c    6.28 (Berkeley) %G% (with NEWDB)";
+static char sccsid[] = "@(#)alias.c    6.29 (Berkeley) %G% (with NEWDB)";
 #endif
 #else
 #ifdef NDBM
 #endif
 #else
 #ifdef NDBM
-static char sccsid[] = "@(#)alias.c    6.28 (Berkeley) %G% (with NDBM)";
+static char sccsid[] = "@(#)alias.c    6.29 (Berkeley) %G% (with NDBM)";
 #else
 #else
-static char sccsid[] = "@(#)alias.c    6.28 (Berkeley) %G% (without NEWDB or NDBM)";
+static char sccsid[] = "@(#)alias.c    6.29 (Berkeley) %G% (without NEWDB or NDBM)";
 #endif
 #endif
 #endif /* not lint */
 #endif
 #endif
 #endif /* not lint */
@@ -147,6 +147,7 @@ alias(a, sendq, e)
        if (bitset(EF_VRFYONLY, e->e_flags))
        {
                a->q_flags |= QVERIFIED;
        if (bitset(EF_VRFYONLY, e->e_flags))
        {
                a->q_flags |= QVERIFIED;
+               e->e_nrcpts++;
                return;
        }
        message("aliased to %s", p);
                return;
        }
        message("aliased to %s", p);
index 69f13e5..165bbcd 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef QUEUE
 
 #ifndef lint
 #ifdef QUEUE
-static char sccsid[] = "@(#)queue.c    6.39 (Berkeley) %G% (with queueing)";
+static char sccsid[] = "@(#)queue.c    6.40 (Berkeley) %G% (with queueing)";
 #else
 #else
-static char sccsid[] = "@(#)queue.c    6.39 (Berkeley) %G% (without queueing)";
+static char sccsid[] = "@(#)queue.c    6.40 (Berkeley) %G% (without queueing)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -466,9 +466,22 @@ runqueue(forkflag)
        while (WorkQ != NULL)
        {
                WORK *w = WorkQ;
        while (WorkQ != NULL)
        {
                WORK *w = WorkQ;
+               extern bool shouldqueue();
 
                WorkQ = WorkQ->w_next;
 
                WorkQ = WorkQ->w_next;
-               dowork(w, e);
+
+               /*
+               **  Ignore jobs that are too expensive for the moment.
+               */
+
+               if (shouldqueue(w->w_pri, w->w_ctime))
+               {
+                       if (Verbose)
+                               printf("\nSkipping %s\n", w->w_name + 2);
+                       return;
+               }
+
+               dowork(w->w_name + 2, ForkQueueRuns, e);
                free(w->w_name);
                free((char *) w);
        }
                free(w->w_name);
                free((char *) w);
        }
@@ -732,7 +745,9 @@ workcmpf(a, b)
 **  DOWORK -- do a work request.
 **
 **     Parameters:
 **  DOWORK -- do a work request.
 **
 **     Parameters:
-**             w -- the work request to be satisfied.
+**             id -- the ID of the job to run.
+**             forkflag -- if set, run this in background.
+**             e - the envelope in which to run it.
 **
 **     Returns:
 **             none.
 **
 **     Returns:
 **             none.
@@ -741,33 +756,22 @@ workcmpf(a, b)
 **             The work request is satisfied if possible.
 */
 
 **             The work request is satisfied if possible.
 */
 
-dowork(w, e)
-       register WORK *w;
+dowork(id, forkflag, e)
+       char *id;
+       bool forkflag;
        register ENVELOPE *e;
 {
        register int i;
        register ENVELOPE *e;
 {
        register int i;
-       extern bool shouldqueue();
        extern bool readqf();
 
        if (tTd(40, 1))
        extern bool readqf();
 
        if (tTd(40, 1))
-               printf("dowork: %s pri %ld\n", w->w_name, w->w_pri);
-
-       /*
-       **  Ignore jobs that are too expensive for the moment.
-       */
-
-       if (shouldqueue(w->w_pri, w->w_ctime))
-       {
-               if (Verbose)
-                       printf("\nSkipping %s\n", w->w_name + 2);
-               return;
-       }
+               printf("dowork(%s)\n", id);
 
        /*
        **  Fork for work.
        */
 
 
        /*
        **  Fork for work.
        */
 
-       if (ForkQueueRuns)
+       if (forkflag)
        {
                i = fork();
                if (i < 0)
        {
                i = fork();
                if (i < 0)
@@ -796,7 +800,7 @@ dowork(w, e)
                clearenvelope(e, FALSE);
                e->e_flags |= EF_QUEUERUN;
                e->e_errormode = EM_MAIL;
                clearenvelope(e, FALSE);
                e->e_flags |= EF_QUEUERUN;
                e->e_errormode = EM_MAIL;
-               e->e_id = &w->w_name[2];
+               e->e_id = id;
 # ifdef LOG
                if (LogLevel > 76)
                        syslog(LOG_DEBUG, "%s: dowork, pid=%d", e->e_id,
 # ifdef LOG
                if (LogLevel > 76)
                        syslog(LOG_DEBUG, "%s: dowork, pid=%d", e->e_id,
@@ -809,7 +813,9 @@ dowork(w, e)
                /* read the queue control file -- return if locked */
                if (!readqf(e))
                {
                /* read the queue control file -- return if locked */
                if (!readqf(e))
                {
-                       if (ForkQueueRuns)
+                       if (tTd(40, 4))
+                               printf("readqf(%s) failed\n", e->e_id);
+                       if (forkflag)
                                exit(EX_OK);
                        else
                                return;
                                exit(EX_OK);
                        else
                                return;
@@ -823,7 +829,7 @@ dowork(w, e)
                        sendall(e, SM_DELIVER);
 
                /* finish up and exit */
                        sendall(e, SM_DELIVER);
 
                /* finish up and exit */
-               if (ForkQueueRuns)
+               if (forkflag)
                        finis();
                else
                        dropenvelope(e);
                        finis();
                else
                        dropenvelope(e);
@@ -876,6 +882,9 @@ readqf(e)
        qfp = fopen(qf, "r+");
        if (qfp == NULL)
        {
        qfp = fopen(qf, "r+");
        if (qfp == NULL)
        {
+               if (tTd(40, 8))
+                       printf("readqf(%s): fopen failure (%s)\n",
+                               qf, errstring(errno));
                if (errno != ENOENT)
                        syserr("readqf: no control file %s", qf);
                return FALSE;
                if (errno != ENOENT)
                        syserr("readqf: no control file %s", qf);
                return FALSE;
@@ -888,6 +897,9 @@ readqf(e)
        if (fstat(fileno(qfp), &st) < 0)
        {
                /* must have been being processed by someone else */
        if (fstat(fileno(qfp), &st) < 0)
        {
                /* must have been being processed by someone else */
+               if (tTd(40, 8))
+                       printf("readqf(%s): fstat failure (%s)\n",
+                               qf, errstring(errno));
                fclose(qfp);
                return FALSE;
        }
                fclose(qfp);
                return FALSE;
        }
@@ -901,6 +913,8 @@ readqf(e)
                                e->e_id, st.st_uid, st.st_mode);
                }
 # endif /* LOG */
                                e->e_id, st.st_uid, st.st_mode);
                }
 # endif /* LOG */
+               if (tTd(40, 8))
+                       printf("readqf(%s): bogus file\n", qf);
                fclose(qfp);
                return FALSE;
        }
                fclose(qfp);
                return FALSE;
        }
@@ -908,6 +922,8 @@ readqf(e)
        if (!lockfile(fileno(qfp), qf, LOCK_EX|LOCK_NB))
        {
                /* being processed by another queuer */
        if (!lockfile(fileno(qfp), qf, LOCK_EX|LOCK_NB))
        {
                /* being processed by another queuer */
+               if (tTd(40, 8))
+                       printf("readqf(%s): locked\n", qf);
                if (Verbose)
                        printf("%s: locked\n", e->e_id);
 # ifdef LOG
                if (Verbose)
                        printf("%s: locked\n", e->e_id);
 # ifdef LOG
index 9c5f2a1..f32e1fb 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)recipient.c        6.32.1.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)recipient.c        6.33 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -704,6 +704,7 @@ include(fname, forwarding, ctladdr, sendq, e)
        {
                /* don't do any more now */
                ctladdr->q_flags |= QVERIFIED;
        {
                /* don't do any more now */
                ctladdr->q_flags |= QVERIFIED;
+               e->e_nrcpts++;
                xfclose(fp, "include", fname);
                return 0;
        }
                xfclose(fp, "include", fname);
                return 0;
        }
index bbc217d..29f4711 100644 (file)
@@ -8,9 +8,9 @@
 
 #ifndef lint
 #ifdef USERDB
 
 #ifndef lint
 #ifdef USERDB
-static char sccsid [] = "@(#)udb.c     6.15 (Berkeley) %G% (with USERDB)";
+static char sccsid [] = "@(#)udb.c     6.16 (Berkeley) %G% (with USERDB)";
 #else
 #else
-static char sccsid [] = "@(#)udb.c     6.15 (Berkeley) %G% (without USERDB)";
+static char sccsid [] = "@(#)udb.c     6.16 (Berkeley) %G% (without USERDB)";
 #endif
 #endif
 
 #endif
 #endif
 
@@ -186,6 +186,7 @@ udbexpand(a, sendq, e)
                                if (bitset(EF_VRFYONLY, e->e_flags))
                                {
                                        a->q_flags |= QVERIFIED;
                                if (bitset(EF_VRFYONLY, e->e_flags))
                                {
                                        a->q_flags |= QVERIFIED;
+                                       e->e_nrcpts++;
                                        return EX_OK;
                                }
 
                                        return EX_OK;
                                }