[llvm] r229881 - Assume the original file is created before release in LockFileManager
Ben Langmuir
blangmuir at apple.com
Thu Feb 19 10:22:36 PST 2015
Author: benlangmuir
Date: Thu Feb 19 12:22:35 2015
New Revision: 229881
URL: http://llvm.org/viewvc/llvm-project?rev=229881&view=rev
Log:
Assume the original file is created before release in LockFileManager
This is true in clang, and let's us remove the problematic code that
waits around for the original file and then times out if it doesn't get
created in short order. This caused any 'dead' lock file or legitimate
time out to cause a cascade of timeouts in any processes waiting on the
same lock (even if they only just showed up).
Modified:
llvm/trunk/lib/Support/LockFileManager.cpp
Modified: llvm/trunk/lib/Support/LockFileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/LockFileManager.cpp?rev=229881&r1=229880&r2=229881&view=diff
==============================================================================
--- llvm/trunk/lib/Support/LockFileManager.cpp (original)
+++ llvm/trunk/lib/Support/LockFileManager.cpp Thu Feb 19 12:22:35 2015
@@ -187,8 +187,7 @@ LockFileManager::WaitForUnlockResult Loc
Interval.tv_nsec = 1000000;
#endif
// Don't wait more than one minute for the file to appear.
- unsigned MaxSeconds = 60;
- bool LockFileGone = false;
+ const unsigned MaxSeconds = 60;
do {
// Sleep for the designated interval, to allow the owning process time to
// finish up and remove the lock file.
@@ -199,47 +198,18 @@ LockFileManager::WaitForUnlockResult Loc
#else
nanosleep(&Interval, nullptr);
#endif
- bool LockFileJustDisappeared = false;
- // If the lock file is still expected to be there, check whether it still
- // is.
- if (!LockFileGone) {
- if (sys::fs::access(LockFileName.c_str(), sys::fs::AccessMode::Exist) ==
- errc::no_such_file_or_directory) {
- LockFileGone = true;
- LockFileJustDisappeared = true;
- }
+ if (sys::fs::access(LockFileName.c_str(), sys::fs::AccessMode::Exist) ==
+ errc::no_such_file_or_directory) {
+ // If the original file wasn't created, somone thought the lock was dead.
+ if (!sys::fs::exists(FileName.str()))
+ return Res_OwnerDied;
+ return Res_Success;
}
- // If the lock file is no longer there, check if the original file is
- // available now.
- if (LockFileGone) {
- if (sys::fs::exists(FileName.str())) {
- return Res_Success;
- }
-
- // The lock file is gone, so now we're waiting for the original file to
- // show up. If this just happened, reset our waiting intervals and keep
- // waiting.
- if (LockFileJustDisappeared) {
- MaxSeconds = 5;
-
-#if LLVM_ON_WIN32
- Interval = 1;
-#else
- Interval.tv_sec = 0;
- Interval.tv_nsec = 1000000;
-#endif
- continue;
- }
- }
-
- // If we're looking for the lock file to disappear, but the process
- // owning the lock died without cleaning up, just bail out.
- if (!LockFileGone &&
- !processStillExecuting((*Owner).first, (*Owner).second)) {
+ // If the process owning the lock died without cleaning up, just bail out.
+ if (!processStillExecuting((*Owner).first, (*Owner).second))
return Res_OwnerDied;
- }
// Exponentially increase the time we wait for the lock to be removed.
#if LLVM_ON_WIN32
More information about the llvm-commits
mailing list