bitbake/utils.py: Teach unlockfile about shared mode lockfiles

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2011-01-19 13:30:14 +00:00
parent 542cebbc32
commit fd88588df0
1 changed files with 7 additions and 1 deletions

View File

@ -445,7 +445,13 @@ def unlockfile(lf):
"""
Unlock a file locked using lockfile()
"""
os.unlink(lf.name)
try:
# If we had a shared lock, we need to promote to exclusive before
# removing the lockfile. Attempt this, ignore failures.
fcntl.flock(lf.fileno(), fcntl.LOCK_EX|fcntl.LOCK_NB)
os.unlink(lf.name)
except IOError:
pass
fcntl.flock(lf.fileno(), fcntl.LOCK_UN)
lf.close()