summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-22 15:12:15 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-24 09:08:14 +0100
commit663470c94a984a47f0ccacf0ede0a079b728ae1c (patch)
tree2bce4dae2fd13cf97576bea23ab2b8bf037d372f /bitbake/lib
parentb991cc4f8954711add94514f7d59efd68cb29ac7 (diff)
downloadpoky-663470c94a984a47f0ccacf0ede0a079b728ae1c.tar.gz
bitbake: cooker: Explictly shut down the sync thread
Hongxu Jia reported a problem where the bb_cache files were not always being written out correctly. This was due to the sync thread being terminated prematurely. Whilst the preceeding changes mean the exit handler for this thread is now correctly called since we switch to using sys.exit() instead of os._exit(), this write can happen after we drop the bitbake lock, leading to potential races. Avoid that headache by adding in explicit thread join() calls before we drop the lock (which atexit or Finalize can't do). (Bitbake rev: afd1900939f7b042297558f4cb01f50f3a299267) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/cooker.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 05be9bef67..33452e7b93 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1674,6 +1674,7 @@ class BBCooker:
1674 1674
1675 if self.parser: 1675 if self.parser:
1676 self.parser.shutdown(clean=not force, force=force) 1676 self.parser.shutdown(clean=not force, force=force)
1677 self.parser.final_cleanup()
1677 1678
1678 def finishcommand(self): 1679 def finishcommand(self):
1679 self.state = state.initial 1680 self.state = state.initial
@@ -2063,6 +2064,7 @@ class CookerParser(object):
2063 2064
2064 self.start() 2065 self.start()
2065 self.haveshutdown = False 2066 self.haveshutdown = False
2067 self.syncthread = None
2066 2068
2067 def start(self): 2069 def start(self):
2068 self.results = self.load_cached() 2070 self.results = self.load_cached()
@@ -2132,8 +2134,8 @@ class CookerParser(object):
2132 c.sync() 2134 c.sync()
2133 2135
2134 sync = threading.Thread(target=sync_caches) 2136 sync = threading.Thread(target=sync_caches)
2137 self.syncthread = sync
2135 sync.start() 2138 sync.start()
2136 multiprocessing.util.Finalize(None, sync.join, exitpriority=-100)
2137 bb.codeparser.parser_cache_savemerge() 2139 bb.codeparser.parser_cache_savemerge()
2138 bb.fetch.fetcher_parse_done() 2140 bb.fetch.fetcher_parse_done()
2139 if self.cooker.configuration.profile: 2141 if self.cooker.configuration.profile:
@@ -2147,6 +2149,10 @@ class CookerParser(object):
2147 bb.utils.process_profilelog(profiles, pout = pout) 2149 bb.utils.process_profilelog(profiles, pout = pout)
2148 print("Processed parsing statistics saved to %s" % (pout)) 2150 print("Processed parsing statistics saved to %s" % (pout))
2149 2151
2152 def final_cleanup(self):
2153 if self.syncthread:
2154 self.syncthread.join()
2155
2150 def load_cached(self): 2156 def load_cached(self):
2151 for mc, cache, filename, appends in self.fromcache: 2157 for mc, cache, filename, appends in self.fromcache:
2152 cached, infos = cache.load(filename, appends) 2158 cached, infos = cache.load(filename, appends)