aboutsummaryrefslogtreecommitdiffstats
path: root/finder
diff options
context:
space:
mode:
authorJeff Gaston <jeffrygaston@google.com>2017-08-22 13:33:19 -0700
committerJeff Gaston <jeffrygaston@google.com>2017-08-22 14:14:40 -0700
commit996716a8e2d538da36f4f1553cf4874fe469d20c (patch)
treea39da42613ebbfe712d34e2f0a7f13e58ab1592e /finder
parentb3f1c8f5f5f4e924902957c3e870bccca61b1910 (diff)
downloadbuild_soong-996716a8e2d538da36f4f1553cf4874fe469d20c.tar.gz
build_soong-996716a8e2d538da36f4f1553cf4874fe469d20c.tar.bz2
build_soong-996716a8e2d538da36f4f1553cf4874fe469d20c.zip
Fix hanging of finder_test
Previously there could be an infinite loop in the Finder's db export when running tests on a system with few cores. The Finder divides the cache-serialization work amongst cores. On systems with enough cores, each path in TestFileSystemRoot would get its own core and the infinite loop in the prefix calculation logic would be avoided. On systems with fewer cores, the computation of the maximum common path could run forever. This shouldn't have affected the general usage of the Finder in builds other than in its unit tests, because the builds don't ask to include the filesystem root as a path to scan. This should only have affected finder_test.go which tested the filesystem root anyway. Bug: 62455338 Test: m -j # which runs unit tests Change-Id: I7a1467fb32e4538fb96833791180bfbfad5a3911
Diffstat (limited to 'finder')
-rw-r--r--finder/finder.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/finder/finder.go b/finder/finder.go
index 8f9496d3..c2df9289 100644
--- a/finder/finder.go
+++ b/finder/finder.go
@@ -661,6 +661,9 @@ func (f *Finder) serializeCacheEntry(dirInfos []dirFullInfo) ([]byte, error) {
for _, info := range infos {
for !strings.HasPrefix(info.P+"/", prefix+"/") {
prefix = filepath.Dir(prefix)
+ if prefix == "/" {
+ break
+ }
}
}
// remove common prefix