From b9e16ac81849a8bf13ca9674606b673733210bf5 Mon Sep 17 00:00:00 2001 From: joe M Date: Fri, 9 Aug 2013 14:54:29 -0500 Subject: 31648: fix timing errors in mailcheck --- Src/utils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Src/utils.c') diff --git a/Src/utils.c b/Src/utils.c index 94ae52284..6d9ffe350 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1287,6 +1287,7 @@ void preprompt(void) { static time_t lastperiodic; + time_t currentmailcheck; LinkNode ln; int period = getiparam("PERIOD"); int mailcheck = getiparam("MAILCHECK"); @@ -1355,7 +1356,9 @@ preprompt(void) return; /* Check mail */ - if (mailcheck && (int) difftime(time(NULL), lastmailcheck) > mailcheck) { + currentmailcheck = time(NULL); + if (mailcheck && + (int) difftime(currentmailcheck, lastmailcheck) > mailcheck) { char *mailfile; if (mailpath && *mailpath && **mailpath) @@ -1371,7 +1374,7 @@ preprompt(void) } unqueue_signals(); } - lastmailcheck = time(NULL); + lastmailcheck = currentmailcheck; } if (prepromptfns) { @@ -1431,7 +1434,7 @@ checkmailpath(char **s) } } else if (shout) { if (st.st_size && st.st_atime <= st.st_mtime && - st.st_mtime > lastmailcheck) { + st.st_mtime >= lastmailcheck) { if (!u) { fprintf(shout, "You have new mail.\n"); fflush(shout); -- cgit v1.2.3