print better diagnostic information on sfgets timeouts
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 4 Jun 1993 08:01:35 +0000 (00:01 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 4 Jun 1993 08:01:35 +0000 (00:01 -0800)
SCCS-vsn: usr.sbin/sendmail/src/usersmtp.c 6.33
SCCS-vsn: usr.sbin/sendmail/src/srvrsmtp.c 6.59
SCCS-vsn: usr.sbin/sendmail/src/collect.c 6.20
SCCS-vsn: usr.sbin/sendmail/src/util.c 6.20

usr/src/usr.sbin/sendmail/src/collect.c
usr/src/usr.sbin/sendmail/src/srvrsmtp.c
usr/src/usr.sbin/sendmail/src/usersmtp.c
usr/src/usr.sbin/sendmail/src/util.c

index f80daee..0bd9b12 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)collect.c  6.19 (Berkeley) %G%";
+static char sccsid[] = "@(#)collect.c  6.20 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <errno.h>
 #endif /* not lint */
 
 # include <errno.h>
@@ -69,7 +69,8 @@ maketemp(from)
        **  Try to read a UNIX-style From line
        */
 
        **  Try to read a UNIX-style From line
        */
 
-       if (sfgets(buf, MAXLINE, InChannel, TimeOuts.to_datablock) == NULL)
+       if (sfgets(buf, MAXLINE, InChannel, TimeOuts.to_datablock,
+                       "initial message read") == NULL)
                goto readerr;
        fixcrlf(buf, FALSE);
 # ifndef NOTUNIX
                goto readerr;
        fixcrlf(buf, FALSE);
 # ifndef NOTUNIX
@@ -78,7 +79,8 @@ maketemp(from)
                if (!flusheol(buf, InChannel))
                        goto readerr;
                eatfrom(buf, e);
                if (!flusheol(buf, InChannel))
                        goto readerr;
                eatfrom(buf, e);
-               if (sfgets(buf, MAXLINE, InChannel, TimeOuts.to_datablock) == NULL)
+               if (sfgets(buf, MAXLINE, InChannel, TimeOuts.to_datablock,
+                               "message header read") == NULL)
                        goto readerr;
                fixcrlf(buf, FALSE);
        }
                        goto readerr;
                fixcrlf(buf, FALSE);
        }
@@ -124,7 +126,9 @@ maketemp(from)
                {
                        int clen;
 
                {
                        int clen;
 
-                       if (sfgets(freebuf, MAXLINE, InChannel, TimeOuts.to_datablock) == NULL)
+                       if (sfgets(freebuf, MAXLINE, InChannel,
+                                       TimeOuts.to_datablock,
+                                       "message header read") == NULL)
                                goto readerr;
 
                        /* is this a continuation line? */
                                goto readerr;
 
                        /* is this a continuation line? */
@@ -200,7 +204,8 @@ maketemp(from)
        if (*workbuf == '\0')
        {
                /* throw away a blank line */
        if (*workbuf == '\0')
        {
                /* throw away a blank line */
-               if (sfgets(buf, MAXLINE, InChannel, TimeOuts.to_datablock) == NULL)
+               if (sfgets(buf, MAXLINE, InChannel, TimeOuts.to_datablock,
+                               "message separator read") == NULL)
                        goto readerr;
        }
        else if (workbuf == buf2)       /* guarantee `buf' contains data */
                        goto readerr;
        }
        else if (workbuf == buf2)       /* guarantee `buf' contains data */
@@ -234,7 +239,8 @@ maketemp(from)
                fputs("\n", tf);
                if (ferror(tf))
                        tferror(tf, e);
                fputs("\n", tf);
                if (ferror(tf))
                        tferror(tf, e);
-       } while (sfgets(buf, MAXLINE, InChannel, TimeOuts.to_datablock) != NULL);
+       } while (sfgets(buf, MAXLINE, InChannel, TimeOuts.to_datablock,
+                       "message body read") != NULL);
 
 readerr:
        if (fflush(tf) != 0)
 
 readerr:
        if (fflush(tf) != 0)
@@ -339,7 +345,8 @@ flusheol(buf, fp)
                if (printmsg)
                        usrerr("553 header line too long");
                printmsg = FALSE;
                if (printmsg)
                        usrerr("553 header line too long");
                printmsg = FALSE;
-               if (sfgets(junkbuf, MAXLINE, fp, TimeOuts.to_datablock) == NULL)
+               if (sfgets(junkbuf, MAXLINE, fp, TimeOuts.to_datablock,
+                               "long line flush") == NULL)
                        return (FALSE);
                p = junkbuf;
        }
                        return (FALSE);
                p = junkbuf;
        }
index 4d1e48c..af51a58 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef SMTP
 
 #ifndef lint
 #ifdef SMTP
-static char sccsid[] = "@(#)srvrsmtp.c 6.58 (Berkeley) %G% (with SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 6.59 (Berkeley) %G% (with SMTP)";
 #else
 #else
-static char sccsid[] = "@(#)srvrsmtp.c 6.58 (Berkeley) %G% (without SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 6.59 (Berkeley) %G% (without SMTP)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -111,7 +111,7 @@ smtp(e)
        }
        settime(e);
        CurHostName = RealHostName;
        }
        settime(e);
        CurHostName = RealHostName;
-       setproctitle("srvrsmtp %s startup", CurHostName);
+       setproctitle("server %s startup", CurHostName);
        expand("\201e", inp, &inp[sizeof inp], e);
        message("220-%s", inp);
        message("220 ESMTP spoken here");
        expand("\201e", inp, &inp[sizeof inp], e);
        message("220-%s", inp);
        message("220 ESMTP spoken here");
@@ -139,9 +139,10 @@ smtp(e)
                (void) fflush(stdout);
 
                /* read the input line */
                (void) fflush(stdout);
 
                /* read the input line */
-               SmtpPhase = "srvrsmtp cmd read";
-               setproctitle("srvrsmtp %s cmd read", CurHostName);
-               p = sfgets(inp, sizeof inp, InChannel, TimeOuts.to_nextcommand);
+               SmtpPhase = "server cmd read";
+               setproctitle("server %s cmd read", CurHostName);
+               p = sfgets(inp, sizeof inp, InChannel, TimeOuts.to_nextcommand,
+                               SmtpPhase);
 
                /* handle errors */
                if (p == NULL)
 
                /* handle errors */
                if (p == NULL)
@@ -203,12 +204,12 @@ smtp(e)
                        if (c->cmdcode == CMDEHLO)
                        {
                                protocol = "ESMTP";
                        if (c->cmdcode == CMDEHLO)
                        {
                                protocol = "ESMTP";
-                               SmtpPhase = "EHLO";
+                               SmtpPhase = "server EHLO";
                        }
                        else
                        {
                                protocol = "SMTP";
                        }
                        else
                        {
                                protocol = "SMTP";
-                               SmtpPhase = "HELO";
+                               SmtpPhase = "server HELO";
                        }
                        sendinghost = newstr(p);
                        if (strcasecmp(p, RealHostName) != 0)
                        }
                        sendinghost = newstr(p);
                        if (strcasecmp(p, RealHostName) != 0)
@@ -223,7 +224,7 @@ smtp(e)
                        break;
 
                  case CMDMAIL:         /* mail -- designate sender */
                        break;
 
                  case CMDMAIL:         /* mail -- designate sender */
-                       SmtpPhase = "MAIL";
+                       SmtpPhase = "server MAIL";
 
                        /* check for validity of this command */
                        if (!gothello)
 
                        /* check for validity of this command */
                        if (!gothello)
@@ -395,7 +396,7 @@ smtp(e)
                                usrerr("503 Need MAIL before RCPT");
                                break;
                        }
                                usrerr("503 Need MAIL before RCPT");
                                break;
                        }
-                       SmtpPhase = "RCPT";
+                       SmtpPhase = "server RCPT";
                        if (setjmp(TopFrame) > 0)
                        {
                                e->e_flags &= ~EF_FATALERRS;
                        if (setjmp(TopFrame) > 0)
                        {
                                e->e_flags &= ~EF_FATALERRS;
@@ -430,7 +431,7 @@ smtp(e)
                        break;
 
                  case CMDDATA:         /* data -- text of mail */
                        break;
 
                  case CMDDATA:         /* data -- text of mail */
-                       SmtpPhase = "DATA";
+                       SmtpPhase = "server DATA";
                        if (!gotmail)
                        {
                                message("503 Need MAIL command");
                        if (!gotmail)
                        {
                                message("503 Need MAIL command");
@@ -826,7 +827,7 @@ runinchild(label, e)
                        auto int st;
 
                        /* parent -- wait for child to complete */
                        auto int st;
 
                        /* parent -- wait for child to complete */
-                       setproctitle("srvrsmtp %s child wait", CurHostName);
+                       setproctitle("server %s child wait", CurHostName);
                        st = waitfor(childpid);
                        if (st == -1)
                                syserr("%s: lost child", label);
                        st = waitfor(childpid);
                        if (st == -1)
                                syserr("%s: lost child", label);
index ba74a85..1d15c5b 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef SMTP
 
 #ifndef lint
 #ifdef SMTP
-static char sccsid[] = "@(#)usersmtp.c 6.32 (Berkeley) %G% (with SMTP)";
+static char sccsid[] = "@(#)usersmtp.c 6.33 (Berkeley) %G% (with SMTP)";
 #else
 #else
-static char sccsid[] = "@(#)usersmtp.c 6.32 (Berkeley) %G% (without SMTP)";
+static char sccsid[] = "@(#)usersmtp.c 6.33 (Berkeley) %G% (without SMTP)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -110,7 +110,7 @@ smtpinit(m, mci, e)
        **      happen.
        */
 
        **      happen.
        */
 
-       SmtpPhase = mci->mci_phase = "greeting wait";
+       SmtpPhase = mci->mci_phase = "client greeting";
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_initial, esmtp_check);
        if (r < 0 || REPLYTYPE(r) != 2)
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_initial, esmtp_check);
        if (r < 0 || REPLYTYPE(r) != 2)
@@ -128,12 +128,12 @@ tryhelo:
        if (bitset(MCIF_ESMTP, mci->mci_flags))
        {
                smtpmessage("EHLO %s", m, mci, MyHostName);
        if (bitset(MCIF_ESMTP, mci->mci_flags))
        {
                smtpmessage("EHLO %s", m, mci, MyHostName);
-               SmtpPhase = mci->mci_phase = "EHLO wait";
+               SmtpPhase = mci->mci_phase = "client EHLO";
        }
        else
        {
                smtpmessage("HELO %s", m, mci, MyHostName);
        }
        else
        {
                smtpmessage("HELO %s", m, mci, MyHostName);
-               SmtpPhase = mci->mci_phase = "HELO wait";
+               SmtpPhase = mci->mci_phase = "client HELO";
        }
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_helo, helo_options);
        }
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_helo, helo_options);
@@ -326,7 +326,7 @@ smtpmailfrom(m, mci, e)
                smtpmessage("MAIL From:<@%s%c%s>%s", m, mci, MyHostName,
                        buf[0] == '@' ? ',' : ':', buf, optbuf);
        }
                smtpmessage("MAIL From:<@%s%c%s>%s", m, mci, MyHostName,
                        buf[0] == '@' ? ',' : ':', buf, optbuf);
        }
-       SmtpPhase = mci->mci_phase = "MAIL wait";
+       SmtpPhase = mci->mci_phase = "client MAIL";
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_mail, NULL);
        if (r < 0 || REPLYTYPE(r) == 4)
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_mail, NULL);
        if (r < 0 || REPLYTYPE(r) == 4)
@@ -388,7 +388,7 @@ smtprcpt(to, m, mci, e)
 
        smtpmessage("RCPT To:<%s>", m, mci, to->q_user);
 
 
        smtpmessage("RCPT To:<%s>", m, mci, to->q_user);
 
-       SmtpPhase = mci->mci_phase = "RCPT wait";
+       SmtpPhase = mci->mci_phase = "client RCPT";
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_rcpt, NULL);
        if (r < 0 || REPLYTYPE(r) == 4)
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_rcpt, NULL);
        if (r < 0 || REPLYTYPE(r) == 4)
@@ -441,7 +441,7 @@ smtpdata(m, mci, e)
 
        /* send the command and check ok to proceed */
        smtpmessage("DATA", m, mci);
 
        /* send the command and check ok to proceed */
        smtpmessage("DATA", m, mci);
-       SmtpPhase = mci->mci_phase = "DATA wait";
+       SmtpPhase = mci->mci_phase = "client DATA 354";
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_datainit, NULL);
        if (r < 0 || REPLYTYPE(r) == 4)
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_datainit, NULL);
        if (r < 0 || REPLYTYPE(r) == 4)
@@ -478,7 +478,7 @@ smtpdata(m, mci, e)
                nmessage(">>> .");
 
        /* check for the results of the transaction */
                nmessage(">>> .");
 
        /* check for the results of the transaction */
-       SmtpPhase = mci->mci_phase = "result wait";
+       SmtpPhase = mci->mci_phase = "client DATA 250";
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_datafinal, NULL);
        if (r < 0)
        setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
        r = reply(m, mci, e, TimeOuts.to_datafinal, NULL);
        if (r < 0)
@@ -526,6 +526,7 @@ smtpquit(m, mci, e)
        /* send the quit message if we haven't gotten I/O error */
        if (mci->mci_state != MCIS_ERROR)
        {
        /* send the quit message if we haven't gotten I/O error */
        if (mci->mci_state != MCIS_ERROR)
        {
+               SmtpPhase = "client QUIT";
                smtpmessage("QUIT", m, mci);
                (void) reply(m, mci, e, TimeOuts.to_quit, NULL);
                if (mci->mci_state == MCIS_CLOSED)
                smtpmessage("QUIT", m, mci);
                (void) reply(m, mci, e, TimeOuts.to_quit, NULL);
                if (mci->mci_state == MCIS_CLOSED)
@@ -548,6 +549,7 @@ smtprset(m, mci, e)
 {
        int r;
 
 {
        int r;
 
+       SmtpPhase = "client RSET";
        smtpmessage("RSET", m, mci);
        r = reply(m, mci, e, TimeOuts.to_rset, NULL);
        if (r < 0)
        smtpmessage("RSET", m, mci);
        r = reply(m, mci, e, TimeOuts.to_rset, NULL);
        if (r < 0)
@@ -571,6 +573,7 @@ smtpprobe(mci)
        extern ENVELOPE BlankEnvelope;
        ENVELOPE *e = &BlankEnvelope;
 
        extern ENVELOPE BlankEnvelope;
        ENVELOPE *e = &BlankEnvelope;
 
+       SmtpPhase = "client probe";
        smtpmessage("RSET", m, mci);
        r = reply(m, mci, e, TimeOuts.to_miscshort, NULL);
        if (r < 0 || REPLYTYPE(r) != 2)
        smtpmessage("RSET", m, mci);
        r = reply(m, mci, e, TimeOuts.to_miscshort, NULL);
        if (r < 0 || REPLYTYPE(r) != 2)
@@ -635,7 +638,7 @@ reply(m, mci, e, timeout, pfunc)
                        fflush(mci->mci_out);
 
                /* get the line from the other side */
                        fflush(mci->mci_out);
 
                /* get the line from the other side */
-               p = sfgets(bufp, MAXLINE, mci->mci_in, timeout);
+               p = sfgets(bufp, MAXLINE, mci->mci_in, timeout, SmtpPhase);
                mci->mci_lastuse = curtime();
 
                if (p == NULL)
                mci->mci_lastuse = curtime();
 
                if (p == NULL)
index 038ea79..f15b7df 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)util.c     6.19 (Berkeley) %G%";
+static char sccsid[] = "@(#)util.c     6.20 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -629,6 +629,7 @@ xfclose(fp, a, b)
 **             siz -- size of buf.
 **             fp -- file to read from.
 **             timeout -- the timeout before error occurs.
 **             siz -- size of buf.
 **             fp -- file to read from.
 **             timeout -- the timeout before error occurs.
+**             during -- what we are trying to read (for error messages).
 **
 **     Returns:
 **             NULL on error (including timeout).  This will also leave
 **
 **     Returns:
 **             NULL on error (including timeout).  This will also leave
@@ -642,11 +643,12 @@ xfclose(fp, a, b)
 static jmp_buf CtxReadTimeout;
 
 char *
 static jmp_buf CtxReadTimeout;
 
 char *
-sfgets(buf, siz, fp, timeout)
+sfgets(buf, siz, fp, timeout, during)
        char *buf;
        int siz;
        FILE *fp;
        time_t timeout;
        char *buf;
        int siz;
        FILE *fp;
        time_t timeout;
+       char *during;
 {
        register EVENT *ev = NULL;
        register char *p;
 {
        register EVENT *ev = NULL;
        register char *p;
@@ -659,11 +661,12 @@ sfgets(buf, siz, fp, timeout)
                {
 # ifdef LOG
                        syslog(LOG_NOTICE,
                {
 # ifdef LOG
                        syslog(LOG_NOTICE,
-                           "timeout waiting for input from %s\n",
-                           CurHostName? CurHostName: "local");
+                           "timeout waiting for input from %s during %s\n",
+                           CurHostName? CurHostName: "local", during);
 # endif
                        errno = 0;
 # endif
                        errno = 0;
-                       usrerr("451 timeout waiting for input");
+                       usrerr("451 timeout waiting for input during %s",
+                               during);
                        buf[0] = '\0';
                        return (NULL);
                }
                        buf[0] = '\0';
                        return (NULL);
                }