From 3568bfeaedca7af63f32719fde6b924902502d69 Mon Sep 17 00:00:00 2001
From: joe9 <joe9mail@gmail.com>
Date: Fri, 9 Aug 2013 14:39:08 -0500
Subject: [PATCH] mailcheck is missing new emails on a dual core machine

date ; echo "mailcheck: $MAILCHECK" ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:19:03 CDT 2013
mailcheck: 1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: ${MAILCHECK}" ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:19:14 CDT 2013
mailcheck: 1
- (0:c:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:19:23 CDT 2013
mailcheck:  1
- (0:c:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:19:27 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:19:29 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:19:30 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:19:31 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:19:32 CDT 2013
mailcheck:  1
/home/j/var/maildir maildir has new mail
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:19:43 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:19:44 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:19:46 CDT 2013
mailcheck:  1
/home/j/var/maildir maildir has new mail
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:20:22 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:20:23 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:20:24 CDT 2013
mailcheck:  1
/home/j/var/maildir maildir has new mail
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:20:25 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:20:26 CDT 2013
mailcheck:  1
/home/j/var/maildir maildir has new mail
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:20:27 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:20:27 CDT 2013
mailcheck:  1
/home/j/var/maildir maildir has new mail
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:20:28 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:20:29 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:20:30 CDT 2013
mailcheck:  1
/home/j/var/maildir maildir has new mail
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
date ; echo "mailcheck: " ${MAILCHECK} ; echo "testing again 123456" | mail -s `echo $USER` joe@localhost
Fri Aug  9 10:20:36 CDT 2013
mailcheck:  1
- (0:i:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
---
 Src/utils.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Src/utils.c b/Src/utils.c
index 26e2a5c..a826fa4 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");
@@ -1348,7 +1349,9 @@ preprompt(void)
 	return;
 
     /* Check mail */
-    if (mailcheck && (int) difftime(time(NULL), lastmailcheck) > mailcheck) {
+    currentmailcheck = time(NULL);
+    /* if (mailcheck && (int) difftime(time(NULL), lastmailcheck) > mailcheck) { */
+    if (mailcheck && (int) difftime(currentmailcheck, lastmailcheck) > mailcheck) {
 	char *mailfile;
 
 	if (mailpath && *mailpath && **mailpath)
@@ -1364,7 +1367,7 @@ preprompt(void)
 	    }
 	    unqueue_signals();
 	}
-	lastmailcheck = time(NULL);
+	lastmailcheck = currentmailcheck;
     }
 
     if (prepromptfns) {
@@ -1424,7 +1427,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);
-- 
1.8.1.5

