summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/server/process.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-06-07 14:14:46 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-06-08 21:53:15 +0100
commit5940020cfb721d79111072b3cd5d581fff59561b (patch)
tree915a192e81d9d0ef5b263cf32291136363a1df9d /bitbake/lib/bb/server/process.py
parent96e34de6f0c485307d1018910bca642d3cdb58e9 (diff)
downloadpoky-5940020cfb721d79111072b3cd5d581fff59561b.tar.gz
bitbake: server/process: Avoid risk of exception deadlocks
The open coded lock acquire/release in the UI event handler doesn't cover the case an exception occurs and if one did, it could deadlock the code. Switch to use 'with' statements which would handle this possibility. We have seen deadlocks in the UI at exit this so this removes a possible cause. (Bitbake rev: bd12792f28efd2f03510653ec947ebf961315272) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/server/process.py')
-rw-r--r--bitbake/lib/bb/server/process.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index 613956f30f..74b74dc39b 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -667,18 +667,14 @@ class BBUIEventQueue:
667 self.t.start() 667 self.t.start()
668 668
669 def getEvent(self): 669 def getEvent(self):
670 self.eventQueueLock.acquire() 670 with self.eventQueueLock:
671 671 if len(self.eventQueue) == 0:
672 if len(self.eventQueue) == 0: 672 return None
673 self.eventQueueLock.release()
674 return None
675
676 item = self.eventQueue.pop(0)
677 673
678 if len(self.eventQueue) == 0: 674 item = self.eventQueue.pop(0)
679 self.eventQueueNotify.clear() 675 if len(self.eventQueue) == 0:
676 self.eventQueueNotify.clear()
680 677
681 self.eventQueueLock.release()
682 return item 678 return item
683 679
684 def waitEvent(self, delay): 680 def waitEvent(self, delay):
@@ -686,10 +682,9 @@ class BBUIEventQueue:
686 return self.getEvent() 682 return self.getEvent()
687 683
688 def queue_event(self, event): 684 def queue_event(self, event):
689 self.eventQueueLock.acquire() 685 with self.eventQueueLock:
690 self.eventQueue.append(event) 686 self.eventQueue.append(event)
691 self.eventQueueNotify.set() 687 self.eventQueueNotify.set()
692 self.eventQueueLock.release()
693 688
694 def send_event(self, event): 689 def send_event(self, event):
695 self.queue_event(pickle.loads(event)) 690 self.queue_event(pickle.loads(event))