]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake/utils.py: Add option of holding shared lockfiles
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 19 Jan 2011 11:01:54 +0000 (11:01 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 21 Feb 2011 13:24:11 +0000 (13:24 +0000)
(From Poky rev: 7857834691868b7f48f732ee78d8770f5473ff68)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/utils.py

index dbed7950effc9deacaeabe517d0d876192692334..d803c732a976b52f064533704a91a47148cff2cf 100644 (file)
@@ -399,7 +399,7 @@ def fileslocked(files):
     for lock in locks:
         bb.utils.unlockfile(lock)
 
-def lockfile(name):
+def lockfile(name, shared=False):
     """
     Use the file fn as a lock file, return when the lock has been acquired.
     Returns a variable to pass to unlockfile().
@@ -413,6 +413,10 @@ def lockfile(name):
         logger.error("Error, lockfile path is not writable!: %s" % path)
         sys.exit(1)
 
+    op = fcntl.LOCK_EX
+    if shared:
+        op = fcntl.LOCK_SH
+
     while True:
         # If we leave the lockfiles lying around there is no problem
         # but we should clean up after ourselves. This gives potential
@@ -427,7 +431,7 @@ def lockfile(name):
         try:
             lf = open(name, 'a+')
             fileno = lf.fileno()
-            fcntl.flock(fileno, fcntl.LOCK_EX)
+            fcntl.flock(fileno, op)
             statinfo = os.fstat(fileno)
             if os.path.exists(lf.name):
                 statinfo2 = os.stat(lf.name)