summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/server
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:33:00 +0000
commit11698e027d71967153b272bf34996bee8f3908e5 (patch)
treeb395b1cb5f167d9c7d190bd13a1d33b670572a3b /bitbake/lib/bb/server
parentbd1edfa3d5b1c24cd1192620f7085ee1df03e1af (diff)
downloadpoky-11698e027d71967153b272bf34996bee8f3908e5.tar.gz
bitbake: 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. (Bitbake rev: b986eac18b6a8bf633f5ef15f32f68de4c86173b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/server')
-rw-r--r--bitbake/lib/bb/server/process.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index 529196b78c..8d12f00bd4 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -361,20 +361,21 @@ class ProcessServer():
361 except FileNotFoundError: 361 except FileNotFoundError:
362 return None 362 return None
363 363
364 lockcontents = get_lock_contents(lockfile)
365 serverlog("Original lockfile contents: " + str(lockcontents))
366
367 lock.close() 364 lock.close()
368 lock = None 365 lock = None
369 366
370 while not lock: 367 while not lock:
371 i = 0 368 i = 0
372 lock = None 369 lock = None
370 if not os.path.exists(os.path.basename(lockfile)):
371 serverlog("Lockfile directory gone, exiting.")
372 return
373
373 while not lock and i < 30: 374 while not lock and i < 30:
374 lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=False) 375 lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=False)
375 if not lock: 376 if not lock:
376 newlockcontents = get_lock_contents(lockfile) 377 newlockcontents = get_lock_contents(lockfile)
377 if newlockcontents != lockcontents: 378 if not newlockcontents.startswith([os.getpid() + "\n", os.getpid() + " "]):
378 # A new server was started, the lockfile contents changed, we can exit 379 # A new server was started, the lockfile contents changed, we can exit
379 serverlog("Lockfile now contains different contents, exiting: " + str(newlockcontents)) 380 serverlog("Lockfile now contains different contents, exiting: " + str(newlockcontents))
380 return 381 return