diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-01-19 11:01:54 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-01-19 11:01:54 +0000 |
commit | 7857834691868b7f48f732ee78d8770f5473ff68 (patch) | |
tree | 4dbef271b41506133e1facbbaf7bf43e35179b5c /bitbake | |
parent | e5a629f314228156a0401ca57b260a7bdbd0fb18 (diff) | |
download | poky-7857834691868b7f48f732ee78d8770f5473ff68.tar.gz |
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.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 40b5f2f3dc..5dc7e766f5 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -399,7 +399,7 @@ def fileslocked(files): | |||
399 | for lock in locks: | 399 | for lock in locks: |
400 | bb.utils.unlockfile(lock) | 400 | bb.utils.unlockfile(lock) |
401 | 401 | ||
402 | def lockfile(name): | 402 | def lockfile(name, shared=False): |
403 | """ | 403 | """ |
404 | Use the file fn as a lock file, return when the lock has been acquired. | 404 | Use the file fn as a lock file, return when the lock has been acquired. |
405 | Returns a variable to pass to unlockfile(). | 405 | Returns a variable to pass to unlockfile(). |
@@ -413,6 +413,10 @@ def lockfile(name): | |||
413 | logger.error("Error, lockfile path is not writable!: %s" % path) | 413 | logger.error("Error, lockfile path is not writable!: %s" % path) |
414 | sys.exit(1) | 414 | sys.exit(1) |
415 | 415 | ||
416 | op = fcntl.LOCK_EX | ||
417 | if shared: | ||
418 | op = fcntl.LOCK_SH | ||
419 | |||
416 | while True: | 420 | while True: |
417 | # If we leave the lockfiles lying around there is no problem | 421 | # If we leave the lockfiles lying around there is no problem |
418 | # but we should clean up after ourselves. This gives potential | 422 | # but we should clean up after ourselves. This gives potential |
@@ -427,7 +431,7 @@ def lockfile(name): | |||
427 | try: | 431 | try: |
428 | lf = open(name, 'a+') | 432 | lf = open(name, 'a+') |
429 | fileno = lf.fileno() | 433 | fileno = lf.fileno() |
430 | fcntl.flock(fileno, fcntl.LOCK_EX) | 434 | fcntl.flock(fileno, op) |
431 | statinfo = os.fstat(fileno) | 435 | statinfo = os.fstat(fileno) |
432 | if os.path.exists(lf.name): | 436 | if os.path.exists(lf.name): |
433 | statinfo2 = os.stat(lf.name) | 437 | statinfo2 = os.stat(lf.name) |