diff mbox series

[scarthgap,2.8,3/4] utils: Add signal blocking for lock_timeout

Message ID ec72e9e6cc268e5e6af89f8c627b4c5409c65048.1741206585.git.steve@sakoman.com
State New
Headers show
Series [scarthgap,2.8,1/4] utils: Print information about lock issue before exiting | expand

Commit Message

Steve Sakoman March 5, 2025, 10:09 p.m. UTC
From: Richard Purdie <richard.purdie@linuxfoundation.org>

We never want to exit whilst holding these locks as it deadlocks all python
threads. Add signal blocking around the lock critical part so a signal
shouldn't cause such an exit.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit a097755c671e2b530dea6200a94b39fa9dca246c)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 lib/bb/utils.py | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 83e832c33..da026fe5b 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -1860,6 +1860,7 @@  def path_is_descendant(descendant, ancestor):
 @contextmanager
 def lock_timeout(lock):
     try:
+        s = signal.pthread_sigmask(signal.SIG_BLOCK, signal.valid_signals())
         held = lock.acquire(timeout=5*60)
         if not held:
             bb.server.process.serverlog("Couldn't get the lock for 5 mins, timed out, exiting.\n%s" % traceback.format_stack())
@@ -1867,3 +1868,4 @@  def lock_timeout(lock):
         yield held
     finally:
         lock.release()
+        signal.pthread_sigmask(signal.SIG_SETMASK, s)