zsh-workers
 help / color / mirror / code / Atom feed
* patch to mailcheck missing new emails
@ 2013-08-09 19:54 joe M
  2013-08-10 18:51 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: joe M @ 2013-08-09 19:54 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 5214 bytes --]

Hello,

I am noticing that mailcheck is missing some emails while comparing
the files' modification time with the lastmailcheck. It is also
missing any emails created/received while the mailcheck process is
running.

I am attaching the patch that fixes the issue. This is my first patch
to zsh, hence, am not sure if it adheres to any guidelines.

This is a sample of what I noticed 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:~)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

Thanks
Joe

[-- Attachment #2: 0001-mailcheck-is-missing-new-emails-on-a-dual-core-machi.patch --]
[-- Type: application/octet-stream, Size: 6294 bytes --]

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: patch to mailcheck missing new emails
  2013-08-09 19:54 patch to mailcheck missing new emails joe M
@ 2013-08-10 18:51 ` Peter Stephenson
  2013-08-11 18:36   ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2013-08-10 18:51 UTC (permalink / raw)
  To: zsh-workers

On Fri, 9 Aug 2013 14:54:29 -0500
joe M <joe9mail@gmail.com> wrote:
> I am noticing that mailcheck is missing some emails while comparing
> the files' modification time with the lastmailcheck. It is also
> missing any emails created/received while the mailcheck process is
> running.
> 
> I am attaching the patch that fixes the issue. This is my first patch
> to zsh, hence, am not sure if it adheres to any guidelines.

Thanks, that looks very plausible and I've committed it (with a couple
of entirely cosmetic changes).

(Separate issue noted in passing: we should probably use zlong for
period and mailcheck to be safe; efficiency isn't really an issue.)

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: patch to mailcheck missing new emails
  2013-08-10 18:51 ` Peter Stephenson
@ 2013-08-11 18:36   ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2013-08-11 18:36 UTC (permalink / raw)
  To: zsh-workers

On Sat, 10 Aug 2013 19:51:38 +0100
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> (Separate issue noted in passing: we should probably use zlong for
> period and mailcheck to be safe; efficiency isn't really an issue.)

Joe sent me a patch, but I'd already done the following (very similar)
which I might as well post...

diff --git a/Src/utils.c b/Src/utils.c
index 6d9ffe3..d1d9406 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1289,8 +1289,8 @@ preprompt(void)
     static time_t lastperiodic;
     time_t currentmailcheck;
     LinkNode ln;
-    int period = getiparam("PERIOD");
-    int mailcheck = getiparam("MAILCHECK");
+    zlong period = getiparam("PERIOD");
+    zlong mailcheck = getiparam("MAILCHECK");
 
     /*
      * Handle any pending window size changes before we compute prompts,
@@ -1338,7 +1338,7 @@ preprompt(void)
     /* If 1) the parameter PERIOD exists, 2) a hook function for    *
      * "periodic" exists, 3) it's been greater than PERIOD since we *
      * executed any such hook, then execute it now.                 */
-    if (period && (time(NULL) > lastperiodic + period) &&
+    if (period && ((zlong)time(NULL) > (zlong)lastperiodic + period) &&
 	!callhookfunc("periodic", NULL, 1, NULL))
 	lastperiodic = time(NULL);
     if (errflag)
@@ -1358,7 +1358,7 @@ preprompt(void)
     /* Check mail */
     currentmailcheck = time(NULL);
     if (mailcheck &&
-	(int) difftime(currentmailcheck, lastmailcheck) > mailcheck) {
+	(zlong) difftime(currentmailcheck, lastmailcheck) > mailcheck) {
 	char *mailfile;
 
 	if (mailpath && *mailpath && **mailpath)

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-11 18:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-09 19:54 patch to mailcheck missing new emails joe M
2013-08-10 18:51 ` Peter Stephenson
2013-08-11 18:36   ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).