nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] Truncated Email.

2016-03-06 13:06:16
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 |
O_TRUNC | O_WRONLY.  Not O_EXCL.

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
concerned.

Shouldn't be too hard to test with

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

sprinkled through the test code.

Cheers, Ralph.

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>