summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-31 10:16:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-01 07:34:09 +0100
commit4c2f28bf482c2abda937b21217fc41d71f037166 (patch)
tree88d2a9793a671d2b0b575ab6c65a8ca0751b5d10 /bitbake/lib/bb/ui
parent18dfdb08403856c106169a969ce9080c60b7cb51 (diff)
downloadpoky-4c2f28bf482c2abda937b21217fc41d71f037166.tar.gz
bitbake: cooker: properly fix bitbake.lock handling
If the PR server or indeed any other child process takes some time to exit (which it sometimes does when saving its database), it can end up holding bitbake.lock after the UI exits, which led to errors if you ran bitbake commands successively - we saw this when running the PR server oe-selftest tests in OE-Core. The recent attempt to fix this wasn't quite right and ended up breaking memory resident bitbake. This time we close the lock file when cooker shuts down (inside the UI process) instead of unlocking it, and this is done in the cooker code rather than the actual UI code so it doesn't matter which UI is in use. Additionally we report that we're waiting for the lock to be released, using lsof or fuser if available to list the processes with the lock open. The 'magic' in the locking is due to all spawned subprocesses of bitbake holding an open file descriptor to the bitbake.lock. It is automatically unlocked when all those fds close the file (as all the processes terminate). We close the UI copy of the lock explicitly, then close the server process copy, any remaining open copy is therefore some proess exiting. (The reproducer for the problem is to set PRSERV_HOST = "localhost:0" and add a call to time.sleep(20) after self.server_close() in lib/prserv/serv.py, then run "bitbake -p; bitbake -p" ). Cleanup work done by Paul Eggleton <paul.eggleton@linux.intel.com>. This reverts bitbake commit 69ecd15aece54753154950c55d7af42f85ad8606 and e97a9f1528d77503b5c93e48e3de9933fbb9f3cd. (Bitbake rev: a29780bd43f74b7326fe788dbd65177b86806fcf) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui')
-rw-r--r--bitbake/lib/bb/ui/knotty.py20
1 files changed, 0 insertions, 20 deletions
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 9788a9287c..2bee242eb0 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -310,7 +310,6 @@ def main(server, eventHandler, params, tf = TerminalFilter):
310 errors = 0 310 errors = 0
311 warnings = 0 311 warnings = 0
312 taskfailures = [] 312 taskfailures = []
313 locktries = 10
314 313
315 termfilter = tf(main, helper, console, errconsole, format) 314 termfilter = tf(main, helper, console, errconsole, format)
316 atexit.register(termfilter.finish) 315 atexit.register(termfilter.finish)
@@ -538,25 +537,6 @@ def main(server, eventHandler, params, tf = TerminalFilter):
538 _, error = server.runCommand(["stateForceShutdown"]) 537 _, error = server.runCommand(["stateForceShutdown"])
539 main.shutdown = 2 538 main.shutdown = 2
540 try: 539 try:
541 topdir, error = server.runCommand(["getVariable", "TOPDIR"])
542 if error:
543 logger.warn("Unable to get the value of TOPDIR variable: %s" % error)
544 else:
545 lockfile = "%s/bitbake.lock" % topdir
546 _, error = server.runCommand(["unlockBitbake"])
547 if error:
548 logger.warn("Unable to unlock the file %s" % lockfile)
549 else:
550 while locktries:
551 lf = bb.utils.lockfile(lockfile, False, False)
552 if not lf:
553 time.sleep(1)
554 locktries -=1
555 else:
556 bb.utils.unlockfile(lf)
557 break
558 if not locktries:
559 logger.warn("Knotty could not lock the file ${TOPDIR}/bitbake.lock, probably locked by cooker and not unlocked yet. Immediate bitbake commands may failed")
560 summary = "" 540 summary = ""
561 if taskfailures: 541 if taskfailures:
562 summary += pluralise("\nSummary: %s task failed:", 542 summary += pluralise("\nSummary: %s task failed:",