in reply to Re^4: locking over the network (rename)
in thread locking over the network

You are writing the file to one file system and then "renaming" it to a different file system? Why? That's rather silly. Renaming to a different file system requires that the contents be copied, which means races leading to partial content. If you need to do that, then I'd copy the file to the new file system under a temporary name (even if you use /bin/mv to do the copying) and then atomically rename from the temporary name (which the receiver should know to ignore) to the real name (which might involve two different directories on the final file system).

You haven't even bothered to read any Unix man pages for rename? Did you want an engraved invitation? They even answer your question about NFS.

Note that Perl's rename is atomic on Win32 including across Samba. No, I don't have links that say this ready to hand to you. You might have to do some research.

- tye        

  • Comment on Re^5: locking over the network (rename)

Replies are listed 'Best First'.
Re^6: locking over the network (rename)
by rovf (Priest) on Feb 01, 2011 at 15:52 UTC
    You are writing the file to one file system and then "renaming" it to a different file system?
    My mistake! Of course the file will always be on the same file system.

    You haven't even bothered to read any Unix man pages for rename?
    I think this doesn't help much here, because this would cover only the case where my process runs on Unix. If at least one of the processes runs on Windows (which might be Windows 2000, XP or Windows 7), the explanations in the Unix man page don't help. What is important here is how Perl implements 'rename' - and yes, I did read the Perldocs for rename, and also the section in 'perlport'.

    -- 
    Ronald Fischer <ynnor@mm.st>
Re^6: locking over the network (rename)
by rowdog (Curate) on Feb 02, 2011 at 02:17 UTC

    POSIX says that ISO C requires rename to be atomic.