@@ -1379,7 +1379,7 @@ def printStatistics(cache):
13791379 called w/ multiple sources : {}
13801380 called w/ PCH : {}""" .strip ()
13811381
1382- with cache .statistics as stats , cache .configuration as cfg :
1382+ with cache .statistics . lock , cache . statistics as stats , cache .configuration as cfg :
13831383 print (template .format (
13841384 str (cache ),
13851385 stats .currentCacheSize (),
@@ -1665,35 +1665,34 @@ def processSingleSource(compiler, cmdLine, sourceFile, objectFile, environment):
16651665def processDirect (cache , objectFile , compiler , cmdLine , sourceFile ):
16661666 manifestHash = ManifestRepository .getManifestHash (compiler , cmdLine , sourceFile )
16671667 manifestHit = None
1668- manifest = cache .getManifest (manifestHash )
1669- if manifest :
1670- for entryIndex , entry in enumerate (manifest .entries ()):
1671- # NOTE: command line options already included in hash for manifest name
1672- try :
1673- includesContentHash = ManifestRepository .getIncludesContentHashForFiles (
1674- [expandBasedirPlaceholder (path ) for path in entry .includeFiles ])
1675-
1676- if entry .includesContentHash == includesContentHash :
1677- cachekey = entry .objectHash
1678- assert cachekey is not None
1679- if entryIndex > 0 :
1680- # Move manifest entry to the top of the entries in the manifest
1681- with cache .manifestLockFor (manifestHash ):
1682- manifest = cache .getManifest (manifestHash ) or Manifest ()
1668+ with cache .manifestLockFor (manifestHash ):
1669+ manifest = cache .getManifest (manifestHash )
1670+ if manifest :
1671+ for entryIndex , entry in enumerate (manifest .entries ()):
1672+ # NOTE: command line options already included in hash for manifest name
1673+ try :
1674+ includesContentHash = ManifestRepository .getIncludesContentHashForFiles (
1675+ [expandBasedirPlaceholder (path ) for path in entry .includeFiles ])
1676+
1677+ if entry .includesContentHash == includesContentHash :
1678+ cachekey = entry .objectHash
1679+ assert cachekey is not None
1680+ if entryIndex > 0 :
1681+ # Move manifest entry to the top of the entries in the manifest
16831682 manifest .touchEntry (cachekey )
16841683 cache .setManifest (manifestHash , manifest )
16851684
1686- manifestHit = True
1687- with cache .lockFor (cachekey ):
1688- if cache .hasEntry (cachekey ):
1689- return processCacheHit (cache , objectFile , cachekey )
1685+ manifestHit = True
1686+ with cache .lockFor (cachekey ):
1687+ if cache .hasEntry (cachekey ):
1688+ return processCacheHit (cache , objectFile , cachekey )
16901689
1691- except IncludeNotFoundException :
1692- pass
1690+ except IncludeNotFoundException :
1691+ pass
16931692
1694- unusableManifestMissReason = Statistics .registerHeaderChangedMiss
1695- else :
1696- unusableManifestMissReason = Statistics .registerSourceChangedMiss
1693+ unusableManifestMissReason = Statistics .registerHeaderChangedMiss
1694+ else :
1695+ unusableManifestMissReason = Statistics .registerSourceChangedMiss
16971696
16981697 if manifestHit is None :
16991698 stripIncludes = False
@@ -1706,21 +1705,21 @@ def processDirect(cache, objectFile, compiler, cmdLine, sourceFile):
17061705 includePaths , compilerOutput = parseIncludesSet (compilerResult [1 ], sourceFile , stripIncludes )
17071706 compilerResult = (compilerResult [0 ], compilerOutput , compilerResult [2 ])
17081707
1709- if manifestHit is not None :
1710- return ensureArtifactsExist (cache , cachekey , unusableManifestMissReason ,
1711- objectFile , compilerResult )
1708+ with cache .manifestLockFor (manifestHash ):
1709+ if manifestHit is not None :
1710+ return ensureArtifactsExist (cache , cachekey , unusableManifestMissReason ,
1711+ objectFile , compilerResult )
17121712
1713- entry = createManifestEntry (manifestHash , includePaths )
1714- cachekey = entry .objectHash
1713+ entry = createManifestEntry (manifestHash , includePaths )
1714+ cachekey = entry .objectHash
17151715
1716- def addManifest ():
1717- with cache .manifestLockFor (manifestHash ):
1716+ def addManifest ():
17181717 manifest = cache .getManifest (manifestHash ) or Manifest ()
17191718 manifest .addEntry (entry )
17201719 cache .setManifest (manifestHash , manifest )
17211720
1722- return ensureArtifactsExist (cache , cachekey , unusableManifestMissReason ,
1723- objectFile , compilerResult , addManifest )
1721+ return ensureArtifactsExist (cache , cachekey , unusableManifestMissReason ,
1722+ objectFile , compilerResult , addManifest )
17241723
17251724
17261725def processNoDirect (cache , objectFile , compiler , cmdLine , environment ):
0 commit comments