diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-06-15 12:00:31 -1000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-06-19 17:06:18 +0100 |
commit | 2dd1b9b305cbbc80eadb26e6c9ad0983c2a23555 (patch) | |
tree | 13f03c5e220e606a6fd5e91d475591047a57fe2f /bitbake/lib/bb | |
parent | b31affa946a1131cfc2f00367f162e747f3bb8e8 (diff) | |
download | poky-2dd1b9b305cbbc80eadb26e6c9ad0983c2a23555.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: 6d2dd16b87ce62086f956912e9a7335b2adfcc94)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 4820d268e2..8788457423 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -1650,6 +1650,7 @@ class BBCooker: | |||
1650 | 1650 | ||
1651 | if self.parser: | 1651 | if self.parser: |
1652 | self.parser.shutdown(clean=not force, force=force) | 1652 | self.parser.shutdown(clean=not force, force=force) |
1653 | self.parser.final_cleanup() | ||
1653 | 1654 | ||
1654 | def finishcommand(self): | 1655 | def finishcommand(self): |
1655 | self.state = state.initial | 1656 | self.state = state.initial |
@@ -2015,6 +2016,7 @@ class CookerParser(object): | |||
2015 | 2016 | ||
2016 | self.start() | 2017 | self.start() |
2017 | self.haveshutdown = False | 2018 | self.haveshutdown = False |
2019 | self.syncthread = None | ||
2018 | 2020 | ||
2019 | def start(self): | 2021 | def start(self): |
2020 | self.results = self.load_cached() | 2022 | self.results = self.load_cached() |
@@ -2081,8 +2083,8 @@ class CookerParser(object): | |||
2081 | self.parser_quit.join_thread() | 2083 | self.parser_quit.join_thread() |
2082 | 2084 | ||
2083 | sync = threading.Thread(target=self.bb_cache.sync) | 2085 | sync = threading.Thread(target=self.bb_cache.sync) |
2086 | self.syncthread = sync | ||
2084 | sync.start() | 2087 | sync.start() |
2085 | multiprocessing.util.Finalize(None, sync.join, exitpriority=-100) | ||
2086 | bb.codeparser.parser_cache_savemerge() | 2088 | bb.codeparser.parser_cache_savemerge() |
2087 | bb.fetch.fetcher_parse_done() | 2089 | bb.fetch.fetcher_parse_done() |
2088 | if self.cooker.configuration.profile: | 2090 | if self.cooker.configuration.profile: |
@@ -2096,6 +2098,10 @@ class CookerParser(object): | |||
2096 | bb.utils.process_profilelog(profiles, pout = pout) | 2098 | bb.utils.process_profilelog(profiles, pout = pout) |
2097 | print("Processed parsing statistics saved to %s" % (pout)) | 2099 | print("Processed parsing statistics saved to %s" % (pout)) |
2098 | 2100 | ||
2101 | def final_cleanup(self): | ||
2102 | if self.syncthread: | ||
2103 | self.syncthread.join() | ||
2104 | |||
2099 | def load_cached(self): | 2105 | def load_cached(self): |
2100 | for filename, appends in self.fromcache: | 2106 | for filename, appends in self.fromcache: |
2101 | cached, infos = self.bb_cache.load(filename, appends) | 2107 | cached, infos = self.bb_cache.load(filename, appends) |