]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake/utils.py: Teach unlockfile about shared mode lockfiles
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 19 Jan 2011 13:30:14 +0000 (13:30 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 19 Jan 2011 13:30:14 +0000 (13:30 +0000)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/utils.py

index 5dc7e766f50353709e060f93a7f7dbe235a49f1b..c6bbae87a49fa7486a87d4a8ff3b394ac1927f45 100644 (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()