[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] Truncated Email.

From: Ralph Corderoy
Subject: Re: [Nmh-workers] Truncated Email.
Date: Sun, 06 Mar 2016 19:05:49 +0000

Hi Ken,

> So, I'm puzzled.  But maybe fetchmail is causing the spool file to be
> rewritten?

The spool file's written by Postfix;  here's two emails arriving, with a
delay in between.  Blank lines are mine.

    $ inotifywait -m /var/spool/mail/ralph
    Setting up watches.
    Watches established.
    /var/spool/mail/ralph OPEN 
    /var/spool/mail/ralph MODIFY 
    /var/spool/mail/ralph CLOSE_WRITE,CLOSE 

    /var/spool/mail/ralph OPEN 
    /var/spool/mail/ralph MODIFY 
    /var/spool/mail/ralph CLOSE_WRITE,CLOSE 

And an inc.

    /var/spool/mail/ralph OPEN 
    /var/spool/mail/ralph ACCESS 
    /var/spool/mail/ralph MODIFY 
    /var/spool/mail/ralph OPEN 
    /var/spool/mail/ralph CLOSE_WRITE,CLOSE 
    /var/spool/mail/ralph CLOSE_NOWRITE,CLOSE 

And there's that first "truncate" close releasing the lock gained on the
first open.

> > Sounds plasible...  I haven't delved deep enough, but wouldn't the
> > creat of [9704, 9712] have failed if the files already existed?
> At least on my system, it says creat() is equivalent to O_CREAT |

Yes, I agree.  Sorry, I meant whatever creates 9704, not that I knew
creat(2) was used.

> > Well, the locks are advisory only, so I don't think the kernel's
> > locking code cares what happens to the file, e.g. writing to it, or
> > truncating it.
> I was more thinking about if you truncate a file with existing locks;
> does it cause further locks to succeed?  I can't really see how that
> would happen unless the spool is rewritten.

No, it doesn't AFAIK.  The file's size is only used for whence and
negative offsets.  nmh always does from 0, specifying a length of 0,
meaning the whole file;  that's "all" not at that instant, but always.
And the locking code doesn't care what happens to the file, e.g.
truncation, as far as checking for checking and granting locks is

Shouldn't be too hard to test with

    sprintf(locks, "awk '$5 == %d' /proc/locks", gettpid());

sprinkled through the test code.

Cheers, Ralph.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]