[ovs-dev] Bug#681880: [bug 681880 1/3] lockfile: Fix hang locking through a dangling symlink.

Bastian Blank waldi at debian.org
Fri Jul 27 06:39:42 UTC 2012


On Thu, Jul 26, 2012 at 02:48:51PM -0700, Ben Pfaff wrote:
> open() with O_CREAT|O_EXCL yields EEXIST if the file being opened is a
> symlink.  lockfile_try_lock() interpreted that error code to mean that
> some other process had created the lock file in the meantime, so it went
> around its loop again, which found out the same thing, which led to a hang.
> 
> This commit fixes the problem by dropping O_EXCL.  I don't see any reason
> that it's actually necessary.  That means that the loop itself is
> unnecessary, so this commit drops that too.

I would always use the lock file at the target location of the database
and not follow symlinks there. Otherwise more than one lock file can
exist.

On second thought, drop the lock file and use fcntl(db, F_SETLK…) on the
database file itself. This lock is automatically released if the process
dies.

Bastian

-- 
Oblivion together does not frighten me, beloved.
		-- Thalassa (in Anne Mulhall's body), "Return to Tomorrow",
		   stardate 4770.3.



More information about the dev mailing list