]> granicus.if.org Git - clang/commitdiff
Diagnose timeouts in the LockFileManager and delete the dead lock file
authorBen Langmuir <blangmuir@apple.com>
Mon, 9 Feb 2015 20:35:13 +0000 (20:35 +0000)
committerBen Langmuir <blangmuir@apple.com>
Mon, 9 Feb 2015 20:35:13 +0000 (20:35 +0000)
If the lock file manager times out, we should give an error rather than
silently trying to load the existing module.  And delete the
(presumably) dead lock file, since it will otherwise prevent progress in
future invokations. This is unsound since we have no way to prove that
the lock file we are deleting is the same one we timed out on, but since
the lock is only to avoid excessive rebuilding anyway it should be okay.
Depends on llvm r228603.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@228604 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticCommonKinds.td
lib/Frontend/CompilerInstance.cpp

index 4e42c1aa15f4a88ff7d73dd877d27812d3e5604a..3afe5966b4ef3fda717584511371ec6ae0cf11e5 100644 (file)
@@ -83,6 +83,8 @@ def err_module_not_found : Error<"module '%0' not found">, DefaultFatal;
 def err_module_not_built : Error<"could not build module '%0'">, DefaultFatal;
 def err_module_lock_failure : Error<
   "could not acquire lock file for module '%0'">, DefaultFatal;
+def err_module_lock_timeout : Error<
+  "timed out waiting to acquire lock file for module '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
 def note_pragma_entered_here : Note<"#pragma entered here">;  
index 9cb26f86c79511c2acab9bc63ac451fb06ac9fc0..187e2b78b8f7032dd1ad7c9944118294865856a8 100644 (file)
@@ -1022,9 +1022,19 @@ static bool compileAndLoadModule(CompilerInstance &ImportingInstance,
     case llvm::LockFileManager::LFS_Shared:
       // Someone else is responsible for building the module. Wait for them to
       // finish.
-      if (Locked.waitForUnlock() == llvm::LockFileManager::Res_OwnerDied)
+      switch (Locked.waitForUnlock()) {
+      case llvm::LockFileManager::Res_Success:
+        ModuleLoadCapabilities |= ASTReader::ARR_OutOfDate;
+        break;
+      case llvm::LockFileManager::Res_OwnerDied:
         continue; // try again to get the lock.
-      ModuleLoadCapabilities |= ASTReader::ARR_OutOfDate;
+      case llvm::LockFileManager::Res_Timeout:
+        Diags.Report(ModuleNameLoc, diag::err_module_lock_timeout)
+            << Module->Name;
+        // Clear the lock file so that future invokations can make progress.
+        Locked.unsafeRemoveLockFile();
+        return false;
+      }
       break;
     }