SCCS-vsn: usr.sbin/sendmail/src/collect.c 8.10
SCCS-vsn: usr.sbin/sendmail/src/util.c 8.38
-static char sccsid[] = "@(#)collect.c 8.9 (Berkeley) %G%";
+static char sccsid[] = "@(#)collect.c 8.10 (Berkeley) %G%";
#endif /* not lint */
# include <errno.h>
#endif /* not lint */
# include <errno.h>
if (smtpmode)
message("354 Enter mail, end with \".\" on a line by itself");
if (smtpmode)
message("354 Enter mail, end with \".\" on a line by itself");
+ /* set global timer to monitor progress */
+ sfgetset(TimeOuts.to_datablock);
+
/*
** Try to read a UNIX-style From line
*/
/*
** Try to read a UNIX-style From line
*/
+ /* reset global timer */
+ sfgetset((time_t) 0);
+
if (fflush(tf) != 0)
tferror(tf, e);
if (fsync(fileno(tf)) < 0 || fclose(tf) < 0)
if (fflush(tf) != 0)
tferror(tf, e);
if (fsync(fileno(tf)) < 0 || fclose(tf) < 0)
-static char sccsid[] = "@(#)util.c 8.37 (Berkeley) %G%";
+static char sccsid[] = "@(#)util.c 8.38 (Berkeley) %G%";
#endif /* not lint */
# include "sendmail.h"
#endif /* not lint */
# include "sendmail.h"
static jmp_buf CtxReadTimeout;
static int readtimeout();
static jmp_buf CtxReadTimeout;
static int readtimeout();
+static EVENT *GlobalTimeout = NULL;
+static bool EnableTimeout = FALSE;
+static int ReadProgress;
char *
sfgets(buf, siz, fp, timeout, during)
char *
sfgets(buf, siz, fp, timeout, during)
- ev = setevent(timeout, readtimeout, 0);
+ if (GlobalTimeout == NULL)
+ ev = setevent(timeout, readtimeout, 0);
+ else
+ EnableTimeout = TRUE;
}
/* clear the event if it has not sprung */
}
/* clear the event if it has not sprung */
+ if (GlobalTimeout == NULL)
+ clrevent(ev);
+ else
+ EnableTimeout = FALSE;
/* clean up the books and exit */
LineNumber++;
/* clean up the books and exit */
LineNumber++;
+void
+sfgetset(timeout)
+ time_t timeout;
+{
+ /* cancel pending timer */
+ if (GlobalTimeout != NULL)
+ {
+ clrevent(GlobalTimeout);
+ GlobalTimeout = NULL;
+ }
+
+ /* schedule fresh one if so requested */
+ if (timeout != 0)
+ {
+ ReadProgress = LineNumber;
+ GlobalTimeout = setevent(timeout, readtimeout, timeout);
+ }
+}
+
+readtimeout(timeout)
+ time_t timeout;
- longjmp(CtxReadTimeout, 1);
+ /* terminate if ordinary timeout */
+ if (GlobalTimeout == NULL)
+ longjmp(CtxReadTimeout, 1);
+
+ /* terminate if no progress was made -- reset state */
+ if (EnableTimeout && (LineNumber <= ReadProgress))
+ {
+ EnableTimeout = FALSE;
+ GlobalTimeout = NULL;
+ longjmp(CtxReadTimeout, 2);
+ }
+
+ /* schedule a new timeout */
+ GlobalTimeout = NULL;
+ sfgetset(timeout);
}
\f/*
** FGETFOLDED -- like fgets, but know about folded lines.
}
\f/*
** FGETFOLDED -- like fgets, but know about folded lines.