summaryrefslogtreecommitdiff
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-01-19 11:01:54 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-01-19 11:01:54 +0000
commit7857834691868b7f48f732ee78d8770f5473ff68 (patch)
tree4dbef271b41506133e1facbbaf7bf43e35179b5c /bitbake
parente5a629f314228156a0401ca57b260a7bdbd0fb18 (diff)
downloadopenembedded-core-7857834691868b7f48f732ee78d8770f5473ff68.tar.gz
openembedded-core-7857834691868b7f48f732ee78d8770f5473ff68.tar.bz2
openembedded-core-7857834691868b7f48f732ee78d8770f5473ff68.tar.xz
openembedded-core-7857834691868b7f48f732ee78d8770f5473ff68.zip
bitbake/utils.py: Add option of holding shared lockfiles
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/utils.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 40b5f2f3d..5dc7e766f 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -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)