diff --git a/include/llvm/Support/LockFileManager.h b/include/llvm/Support/LockFileManager.h index 61c65dabae3..849fe471bf9 100644 --- a/include/llvm/Support/LockFileManager.h +++ b/include/llvm/Support/LockFileManager.h @@ -77,6 +77,10 @@ public: /// \brief For a shared lock, wait until the owner releases the lock. WaitForUnlockResult waitForUnlock(); + + /// \brief Remove the lock file. This may delete a different lock file than + /// the one previously read if there is a race. + std::error_code unsafeRemoveLockFile(); }; } // end namespace llvm diff --git a/lib/Support/LockFileManager.cpp b/lib/Support/LockFileManager.cpp index 5b82c367c0a..9ec52ac5409 100644 --- a/lib/Support/LockFileManager.cpp +++ b/lib/Support/LockFileManager.cpp @@ -186,8 +186,8 @@ LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() { Interval.tv_sec = 0; Interval.tv_nsec = 1000000; #endif - // Don't wait more than five minutes for the file to appear. - unsigned MaxSeconds = 300; + // Don't wait more than one minute for the file to appear. + unsigned MaxSeconds = 60; bool LockFileGone = false; do { // Sleep for the designated interval, to allow the owning process time to @@ -263,3 +263,7 @@ LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() { // Give up. return Res_Timeout; } + +std::error_code LockFileManager::unsafeRemoveLockFile() { + return sys::fs::remove(LockFileName.str()); +}