[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [leafnode-list] lockfile_exists disaster, analysis of 1.9.19 and
Cornelius Krasel writes:
> I suppose you refer to the following sentence of the open(2)
> manpage which I do not immediately understand:
> The solution for performing
> atomic file locking using a lockfile is to create
> a unique file on the same fs (e.g., incorporating
> hostname and pid), use link(2) to make a link to
> the lockfile. If link() returns 0, the lock is
> successful. Otherwise, use stat(2) on the unique
> file to check if its link count has increased to
> 2, in which case the lock is also successful.
> Why should link() fail in the first place?
link() will fail if the lockfile already exists. If the filesystem is
NFS mounted, it's possible for the client and/or the server to retry the
operation and return a failure status even though the original operation
succeeded; that's why you need to check the link count in that case.
But Mom, frogs are our FRIENDS! -- Calvin
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list