diff mbox series

[4/6] cooker: Fix parsing race around cache handling

Message ID 20230121212305.2171310-4-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit f45a94e6720dacf7f51ac147c115a6f608769093
Headers show
Series [1/6] server/process: Fix lockfile contents check bug | expand

Commit Message

Richard Purdie Jan. 21, 2023, 9:23 p.m. UTC
When draining the result queue from the parsing processes, cache objects
can be created even if they are then immediately destroyed. The reset
in the sync code needs to happen after any objects have been created.

Change the ordering to fix this. This ordering has caused various
cache errors, particularly when interrupting parsing with Ctrl+C.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/cooker.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index d15ad2fb2e..527f6a0421 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -2233,6 +2233,14 @@  class CookerParser(object):
         else:
             bb.error("Parsing halted due to errors, see error messages above")
 
+        # Cleanup the queue before call process.join(), otherwise there might be
+        # deadlocks.
+        while True:
+            try:
+               self.result_queue.get(timeout=0.25)
+            except queue.Empty:
+                break
+
         def sync_caches():
             for c in self.bb_caches.values():
                 bb.cache.SiggenRecipeInfo.reset()
@@ -2243,14 +2251,6 @@  class CookerParser(object):
 
         self.parser_quit.set()
 
-        # Cleanup the queue before call process.join(), otherwise there might be
-        # deadlocks.
-        while True:
-            try:
-               self.result_queue.get(timeout=0.25)
-            except queue.Empty:
-                break
-
         for process in self.processes:
             process.join(0.5)