summaryrefslogtreecommitdiffstats
path: root/bitbake/bin
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-01-04 12:32:35 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-01-05 11:50:17 +0000
commita19687acd12497d727203e63d74b2703387f34a6 (patch)
tree813515cdfb0c807435db26acb6bafc2d351f48f1 /bitbake/bin
parent2c6f0b9228b47459dd1b67d578792cd017006128 (diff)
downloadpoky-a19687acd12497d727203e63d74b2703387f34a6.tar.gz
bitbake: lib/bb: Update thread/process locks to use a timeout
The thread/process locks we use translate to futexes in Linux. If a process dies holding the lock, anything else trying to take the lock will hang indefinitely. An example would be the OOM killer taking out a parser process. To avoid bitbake processes just hanging indefinitely, add a timeout to our lock calls using a context manager. If we can't obtain the lock after waiting 5 minutes, hard exit out using os._exit(1). Use _exit() to avoid locking in any other places trying to write error messages to event handler queues (which also need locks). Whilst a bit harsh, this should mean we stop having lots of long running processes in cases where things are never going to work out and also avoids hanging builds on the autobuilder. (Bitbake rev: d2a3f662b0eed900fc012a392bfa0a365df0df9b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-xbitbake/bin/bitbake-worker9
1 files changed, 4 insertions, 5 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index ed266f0ac2..a3ea5d9618 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -121,11 +121,10 @@ def worker_child_fire(event, d):
121 121
122 data = b"<event>" + pickle.dumps(event) + b"</event>" 122 data = b"<event>" + pickle.dumps(event) + b"</event>"
123 try: 123 try:
124 worker_pipe_lock.acquire() 124 with bb.utils.lock_timeout(worker_pipe_lock):
125 while(len(data)): 125 while(len(data)):
126 written = worker_pipe.write(data) 126 written = worker_pipe.write(data)
127 data = data[written:] 127 data = data[written:]
128 worker_pipe_lock.release()
129 except IOError: 128 except IOError:
130 sigterm_handler(None, None) 129 sigterm_handler(None, None)
131 raise 130 raise