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

Re: dot-locking



On Thu, 13 Mar 1997 16:41:00 PST Bruce Perens (bruce@pixar.com) wrote:

> You could leave the flock locking on and surround it with dot-locking.
> To perform dot-locking, create the file <mailbox-name>.lock using
> open(name, O_CREAT|O_EXCL, 0644). Create with O_EXCL will fail if the
> file exists. If you can't create it, sleep for a while and try again.
> To unlock, unlink() the file.

I thought this was the wrong thing to do, as open() is not garanteed atomic across NFS.
>From what I understood, one should:
  open(dummy_name_with_pid_and_machine_name_included, O_CREAT|O_EXCL, 0600);
  link(dummy_name_with_pid_and_machine_name_included, real_lock_file);
as link() is guaranteed atomic across NFS.

Can someone tell which is better ?

Phil.



Reply to: