lockfile: Fix hang locking through a dangling symlink.
authorBen Pfaff <blp@nicira.com>
Thu, 26 Jul 2012 21:36:24 +0000 (14:36 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 1 Aug 2012 17:05:23 +0000 (10:05 -0700)
commit77c513a44ab85264aed7c38387ef221ad30e461c
tree2b733b5bcdbe2bfc1b3c492bd8e4c511d2fcac85
parentb322930908706d7db5cb5d1658c5c64f2642300a
lockfile: Fix hang locking through a dangling symlink.

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.

Debian bug #681880.
CC: 681880@bugs.debian.org
Reported-by: Bastian Blank <waldi@debian.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Reviewed-by: Simon Horman <horms@verge.net.au>
lib/lockfile.c
tests/lockfile.at
tests/test-lockfile.c