diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-04 12:32:35 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-05 11:50:17 +0000 |
commit | a19687acd12497d727203e63d74b2703387f34a6 (patch) | |
tree | 813515cdfb0c807435db26acb6bafc2d351f48f1 /bitbake/lib/bb/cooker.py | |
parent | 2c6f0b9228b47459dd1b67d578792cd017006128 (diff) | |
download | poky-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/lib/bb/cooker.py')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index a5a635858c..738849d189 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -251,14 +251,14 @@ class BBCooker: | |||
251 | self.notifier = pyinotify.Notifier(self.watcher, self.notifications) | 251 | self.notifier = pyinotify.Notifier(self.watcher, self.notifications) |
252 | 252 | ||
253 | def process_inotify_updates(self): | 253 | def process_inotify_updates(self): |
254 | with self.inotify_threadlock: | 254 | with bb.utils.lock_timeout(self.inotify_threadlock): |
255 | for n in [self.confignotifier, self.notifier]: | 255 | for n in [self.confignotifier, self.notifier]: |
256 | if n and n.check_events(timeout=0): | 256 | if n and n.check_events(timeout=0): |
257 | # read notified events and enqueue them | 257 | # read notified events and enqueue them |
258 | n.read_events() | 258 | n.read_events() |
259 | 259 | ||
260 | def process_inotify_updates_apply(self): | 260 | def process_inotify_updates_apply(self): |
261 | with self.inotify_threadlock: | 261 | with bb.utils.lock_timeout(self.inotify_threadlock): |
262 | for n in [self.confignotifier, self.notifier]: | 262 | for n in [self.confignotifier, self.notifier]: |
263 | if n and n.check_events(timeout=0): | 263 | if n and n.check_events(timeout=0): |
264 | n.read_events() | 264 | n.read_events() |