views:

276

answers:

1

I read that file locking on network files isn't very reliable.

I'm using those LockFile/LockFileEx/UnlockFile win32-api functions for range-locks. Does anyone have some experience of using those functions on files living on a network-share?

+2  A: 

Win32 file locking mechanisms are reliable IF they're done to a remote CIFS share. There have been many flat file databases that work just quite reliably using these mechanisms for decades.

They're not reliable if they're done on a remote NFS share (as Jim Lewis mentioned).

Larry Osterman
Actually, he says that NFS might not work because most of the fcntl implementations (on linux!) are broken for this network file system.But he also mentions that "People who have a lot of experience with Windows tell me that file locking of network files is very buggy and is not dependable." Are you sure he also means NFS with network files?
Thomas Danecker
The file locking mechanism in *nix is advisory not mandatory (as it is on Windows). As such network filesystems like NFS which expose *nix's locking mechanism aren't really reliable. This is among the reasons that UW IMAP doesn't support locating the users mailbox store on an NFS share.
Larry Osterman