"Miquel" == Miquel van Smoorenburg <[EMAIL PROTECTED]> writes:

    Miquel> It turns out that while in mbox format (see also the
    Miquel> mbox(5) manpage that comes with qmail) it only takes one
    Miquel> stat() to find out if new mail arrived, you need to scan
    Miquel> the entire new/ and cur/ directories for maildir
    Miquel> format. With a lot of users who potentially have hundreds
    Miquel> of messages in their spool, this can be quite time- and
    Miquel> disk intensive.

    Miquel> Now, with a bit of thinking I found out that this isn't
    Miquel> nessecary at all. The modification time on the tmp/
    Miquel> directory indicates when a new message was last delivered,
    Miquel> since that always goes through tmp/.  The access time on
    Miquel> the new/ directory (set by readdir()) indicates when a
    Miquel> mail program last checked the maildir mbox. So, a complete
    Miquel> scan of new/ and cur/ stat()ing all files isn't nessecary
    Miquel> at all.

 Doesn't the presence of any messages in the new dir indicate "You
have new mail." and the presence of any messages in the cur dir
indicate "You have mail." So you need to do an opendir and a readdir,
but you can stop at the first directory entry that looks like a valid
message. Hopefully I'm not being to naive. I'm hoping that the OS does
_not_ in fact read in the entire directory and then libc just returns
one entry at a time. If this is the case, then while you are saving
some CPU by not iterating though all of the directory entries, the
disk access is still the same, which is likely the expensive part.

j.
--
Jay Soffian <[EMAIL PROTECTED]>                       UNIX Systems Administrator
404.572.1941                                             Cox Interactive Media

Reply via email to