From fd88588df029604689db9b0e30c55aad68392a5d Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 19 Jan 2011 13:30:14 +0000 Subject: [PATCH] bitbake/utils.py: Teach unlockfile about shared mode lockfiles Signed-off-by: Richard Purdie --- bitbake/lib/bb/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 5dc7e766f5..c6bbae87a4 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py @@ -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()