aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-01-14 13:35:08 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-01-14 14:32:52 +0000
commitb986eac18b6a8bf633f5ef15f32f68de4c86173b (patch)
tree7a5dfd023da99bf6ac669e7351cf1d4ca02e52c2
parentbf681d173263cd42ffc143655f61abe0573fd83c (diff)
downloadbitbake-b986eac18b6a8bf633f5ef15f32f68de4c86173b.tar.gz
server/process: Improve lockfile handling at exit
If memory resident bitbake is active and the build directory is renamed upon build completion, several bad things can happen: * the old build directory could be re-created to contain a lockfile leaving an empty directory behind * a lockfile for a new build could be found and attempt to be locked This patch avoids creating an empty directory (not perfectly, but should work in the majority of cases - an empty directory is cosmetic). It also now compares the lock file contents to it's own pid and just exits if it doesn't match, it is clearly then belonging to some new process. This will be combined with bitbake shutdown calls on the autobuilder to ensure "saved" build directories, or build directories being deleted by clobberdir don't do strange things. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/server/process.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index 529196b78..8d12f00bd 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -361,20 +361,21 @@ class ProcessServer():
except FileNotFoundError:
return None
- lockcontents = get_lock_contents(lockfile)
- serverlog("Original lockfile contents: " + str(lockcontents))
-
lock.close()
lock = None
while not lock:
i = 0
lock = None
+ if not os.path.exists(os.path.basename(lockfile)):
+ serverlog("Lockfile directory gone, exiting.")
+ return
+
while not lock and i < 30:
lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=False)
if not lock:
newlockcontents = get_lock_contents(lockfile)
- if newlockcontents != lockcontents:
+ if not newlockcontents.startswith([os.getpid() + "\n", os.getpid() + " "]):
# A new server was started, the lockfile contents changed, we can exit
serverlog("Lockfile now contains different contents, exiting: " + str(newlockcontents))
return