On Fri, Jul 27, 2018 at 01:07:42PM -0500, Derek Martin wrote:
> On Thu, Jul 26, 2018 at 06:39:30PM -0700, Kevin J. McCarthy wrote:
> > My question is about the merit of performing the lstat double-check.
> > Does mutt need to be doing this?  Does this work around some strange bug
> > with certain filesystems or NFS?
> 
> I can't immediately think of a way that NFS is likely to cause
> (additional) problems here...  I think the likely reason to do this is
> to attempt to prevent a race where the source file is replaced at the
> same time as the rename happens (creating a separate file) in which
> case you should not unlink.  The trouble is, if that's the purpose,
> there's still a race between the stat and the unlink...

Thank you Derek.  I'm leaning towards just pulling out the
compare_stat() double check.  I think the link() call is about as atomic
as we can get for the rename, and if it returns 0 we should accept that
it worked.  Trying to fix other race conditions is... as you say, racy
;-)

-- 
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA

Attachment: signature.asc
Description: PGP signature

Reply via email to