From ff4977523552c06f960ab9a124ff3c9f5bef7b7b Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 6 Dec 2013 10:57:05 -0800 Subject: [PATCH] Bug 400073 - More robust clearing of results cache. --- .../cdt/internal/core/pdom/AbstractIndexerTask.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java index a7c6d08cb98..25c5db71438 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java @@ -1017,6 +1017,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { private DependsOnOutdatedFileException parseFile(Object tu, AbstractLanguage lang, IIndexFileLocation ifl, IScannerInfo scanInfo, FileContext ctx, IProgressMonitor pm) throws CoreException, InterruptedException { + boolean resultCacheCleared = false; IPath path= getLabel(ifl); Throwable th= null; try { @@ -1036,6 +1037,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { // to the index. ((ASTTranslationUnit) ast).setOriginatingTranslationUnit((ITranslationUnit) tu); writeToIndex(lang.getLinkageID(), ast, codeReader, ctx, pm); + resultCacheCleared = true; // The cache was cleared while writing to the index. } } catch (CoreException e) { th= e; @@ -1055,8 +1057,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } if (th != null) { swallowError(path, th); - // In case of a parsing error the result cache may not have been cleared. - // Clear if under a write lock to reduce interference with index readers. + } + + if (!resultCacheCleared) { + // If the result cache has not been cleared, clear it under a write lock to reduce + // interference with index readers. fIndex.acquireWriteLock(); try { fIndex.clearResultCache();