about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Src/utils.c9
2 files changed, 10 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index b81522315..7065e309d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-08-10  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 31648: joe M: Src/utils.c: fix timing errors in mailcheck.
+
 2013-08-08  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* Src/Zle/zle_tricky.c (inststrlen): 31644: the wrong length was
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);