try to improve closed connection error handling
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 26 May 1993 10:04:28 +0000 (02:04 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 26 May 1993 10:04:28 +0000 (02:04 -0800)
SCCS-vsn: usr.sbin/sendmail/src/err.c 6.23

usr/src/usr.sbin/sendmail/src/err.c

index dff3a97..4c0a8e8 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)err.c      6.22 (Berkeley) %G%";
+static char sccsid[] = "@(#)err.c      6.23 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -244,28 +244,32 @@ putmsg(msg, holdmsg)
                fprintf(CurEnv->e_xfp, "%s\n", msg);
 
        /* output to channel if appropriate */
                fprintf(CurEnv->e_xfp, "%s\n", msg);
 
        /* output to channel if appropriate */
-       if (!holdmsg && (Verbose || msg[0] != '0'))
-       {
-               (void) fflush(stdout);
-               if (OpMode == MD_SMTP)
-                       fprintf(OutChannel, "%s\r\n", msg);
-               else
-                       fprintf(OutChannel, "%s\n", &msg[4]);
-               if (msg[3] == ' ')
-                       (void) fflush(OutChannel);
-               if (ferror(OutChannel))
-               {
-                       /* can't call syserr, 'cause we are using MsgBuf */
-                       HoldErrs = TRUE;
+       if (holdmsg || (!Verbose && msg[0] == '0'))
+               return;
+
+       (void) fflush(stdout);
+       if (OpMode == MD_SMTP)
+               fprintf(OutChannel, "%s\r\n", msg);
+       else
+               fprintf(OutChannel, "%s\n", &msg[4]);
+       if (msg[3] == ' ')
+               (void) fflush(OutChannel);
+       if (!ferror(OutChannel))
+               return;
+
+       /* error on output -- if reporting lost channel, just ignore it */
+       if (feof(InChannel) || ferror(InChannel))
+               return;
+
+       /* can't call syserr, 'cause we are using MsgBuf */
+       HoldErrs = TRUE;
 #ifdef LOG
 #ifdef LOG
-                       if (LogLevel > 0)
-                               syslog(LOG_CRIT,
-                                       "%s: SYSERR: putmsg (%s): error on output channel sending \"%s\"",
-                                       CurEnv->e_id == NULL ? "NOQUEUE" : CurEnv->e_id,
-                                       CurHostName, msg);
+       if (LogLevel > 0)
+               syslog(LOG_CRIT,
+                       "%s: SYSERR: putmsg (%s): error on output channel sending \"%s\"",
+                       CurEnv->e_id == NULL ? "NOQUEUE" : CurEnv->e_id,
+                       CurHostName, msg);
 #endif
 #endif
-               }
-       }
 }
 \f/*
 **  PUTERRMSG -- like putmsg, but does special processing for error messages
 }
 \f/*
 **  PUTERRMSG -- like putmsg, but does special processing for error messages