summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2008-10-06 08:09:11 +0000
committerRichard Purdie <richard@openedhand.com>2008-10-06 08:09:11 +0000
commitf4337b98030c00bf53ea8cd88ea51a2f091e4ed3 (patch)
tree0a57cf013048d793d678311ca3e3cb98351a4cdc
parent527b3372cdafc988c581f946d79de6f57f0e3cd4 (diff)
downloadpoky-f4337b98030c00bf53ea8cd88ea51a2f091e4ed3.tar.gz
bitbake utils.py: Fix ocassional locking glitch with a better retrying mechanism
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@5415 311d38ba-8fff-0310-9ca6-ca027cbcb966
-rw-r--r--bitbake-dev/lib/bb/utils.py21
-rw-r--r--bitbake/lib/bb/utils.py21
2 files changed, 24 insertions, 18 deletions
diff --git a/bitbake-dev/lib/bb/utils.py b/bitbake-dev/lib/bb/utils.py
index 89506649fb..119f08582d 100644
--- a/bitbake-dev/lib/bb/utils.py
+++ b/bitbake-dev/lib/bb/utils.py
@@ -246,15 +246,18 @@ def lockfile(name):
246 # This implementation is unfair since the last person to request the 246 # This implementation is unfair since the last person to request the
247 # lock is the most likely to win it. 247 # lock is the most likely to win it.
248 248
249 lf = open(name, "a+") 249 try:
250 fcntl.flock(lf.fileno(), fcntl.LOCK_EX) 250 lf = open(name, "a+")
251 statinfo = os.fstat(lf.fileno()) 251 fcntl.flock(lf.fileno(), fcntl.LOCK_EX)
252 if os.path.exists(lf.name): 252 statinfo = os.fstat(lf.fileno())
253 statinfo2 = os.stat(lf.name) 253 if os.path.exists(lf.name):
254 if statinfo.st_ino == statinfo2.st_ino: 254 statinfo2 = os.stat(lf.name)
255 return lf 255 if statinfo.st_ino == statinfo2.st_ino:
256 # File no longer exists or changed, retry 256 return lf
257 lf.close 257 # File no longer exists or changed, retry
258 lf.close
259 except Exception, e:
260 continue
258 261
259def unlockfile(lf): 262def unlockfile(lf):
260 """ 263 """
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index d3701acca7..18fc9f7252 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -246,15 +246,18 @@ def lockfile(name):
246 # This implementation is unfair since the last person to request the 246 # This implementation is unfair since the last person to request the
247 # lock is the most likely to win it. 247 # lock is the most likely to win it.
248 248
249 lf = open(name, "a+") 249 try:
250 fcntl.flock(lf.fileno(), fcntl.LOCK_EX) 250 lf = open(name, "a+")
251 statinfo = os.fstat(lf.fileno()) 251 fcntl.flock(lf.fileno(), fcntl.LOCK_EX)
252 if os.path.exists(lf.name): 252 statinfo = os.fstat(lf.fileno())
253 statinfo2 = os.stat(lf.name) 253 if os.path.exists(lf.name):
254 if statinfo.st_ino == statinfo2.st_ino: 254 statinfo2 = os.stat(lf.name)
255 return lf 255 if statinfo.st_ino == statinfo2.st_ino:
256 # File no longer exists or changed, retry 256 return lf
257 lf.close 257 # File no longer exists or changed, retry
258 lf.close
259 except Exception, e:
260 continue
258 261
259def unlockfile(lf): 262def unlockfile(lf):
260 """ 263 """