Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: New mail notification not working

On Sep 7, 11:52am, Russell Hoover wrote:
} > try recompiling it with --enable-maildir-support.
} My sysadmin has done this, still not getting notification at the shell.
} do I need, e.g., "new" after ".mailspool/rj/" ?

No, you don't need anything after the name of the directory; you don't
even need the trailing slash, though it should be harmless.

I just had a look at the mailstat() function [it get's #defined to be
stat() when maildir support is not enabled]. Let me preface this by
saying that this function was contributed back in 1999 by Miquel van
Smoorenburg <miquels@xxxxxxxxxx> who sent it (as a Debian patch?) to
Clint Adams <schizo@xxxxxxxxxx>. It was not thoroughly debugged by any
of the regular zsh developers, none of whom (as far as I know) uses

Anyway, mailstat() is using a single static structure to keep track of
the last-modified time of the maildir "new" subdir. This means that it
only works correctly if you have exactly one maildir directory in your
mailpath -- if you have multiple maildirs, it gets confused about which
modified-time to compare; it checks each maildir for new-ness against
the modified time of the one preceding it in the mailpath, cycling to
check the first maildir against the last on subsequent calls.

So you ought to be getting notified some of the time, but it would seem
random when you don't know what's going on.

Unfortunately, I don't have time to work on a good patch for this. It'd
have to e.g. keep a lookup table of stat structures keyed on path name.
The quick fix is simply to delete the "optimization" that makes use of
this static structure, but that makes the function hideously expensive;
it may turn out to be too slow for you to use.

Index: Src/utils.c
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/utils.c,v
retrieving revision 1.6
diff -c -r1.6 utils.c
--- Src/utils.c	2001/06/13 05:19:13	1.6
+++ Src/utils.c	2001/09/07 17:08:42
@@ -3745,7 +3745,7 @@
        DIR                     *dd;
        struct                  dirent *fn;
        struct stat             st_ret, st_tmp;
-       static struct stat      st_new_last, st_ret_last;
+       static struct stat      st_ret_last;
        char                    *dir, *file = 0;
        int                     i;
        time_t                  atime = 0, mtime = 0;
@@ -3779,6 +3779,9 @@
        if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
        st_ret.st_mtime = st_tmp.st_mtime;
+       {
+       static struct stat      st_new_last;
        /* Optimization - if new/ didn't change, nothing else did. */
        if (st_tmp.st_dev == st_new_last.st_dev &&
            st_tmp.st_ino == st_new_last.st_ino &&
@@ -3788,6 +3791,8 @@
 	   return 0;
        st_new_last = st_tmp;
+       }
        /* Loop over new/ and cur/ */
        for (i = 0; i < 2; i++) {

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

Messages sorted by: Reverse Date, Date, Thread, Author