[llvm] e05e219 - [LockFileManager] Make default waitForUnlock timeout a parameter, NFC

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 10 15:26:34 PST 2020


Author: Vedant Kumar
Date: 2020-01-10T15:24:32-08:00
New Revision: e05e219926f90ccab927b7b1af6d14aa6dd52571

URL: https://github.com/llvm/llvm-project/commit/e05e219926f90ccab927b7b1af6d14aa6dd52571
DIFF: https://github.com/llvm/llvm-project/commit/e05e219926f90ccab927b7b1af6d14aa6dd52571.diff

LOG: [LockFileManager] Make default waitForUnlock timeout a parameter, NFC

Patch by Xi Ge!

Added: 
    

Modified: 
    llvm/include/llvm/Support/LockFileManager.h
    llvm/lib/Support/LockFileManager.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/LockFileManager.h b/llvm/include/llvm/Support/LockFileManager.h
index 57e4fbd84cd9..2efeca3b6200 100644
--- a/llvm/include/llvm/Support/LockFileManager.h
+++ b/llvm/include/llvm/Support/LockFileManager.h
@@ -77,7 +77,9 @@ class LockFileManager {
   operator LockFileState() const { return getState(); }
 
   /// For a shared lock, wait until the owner releases the lock.
-  WaitForUnlockResult waitForUnlock();
+  /// Total timeout for the file to appear is ~1.5 minutes.
+  /// \param MaxSeconds the maximum wait time per iteration in seconds.
+  WaitForUnlockResult waitForUnlock(const unsigned MaxSeconds = 40);
 
   /// Remove the lock file.  This may delete a 
diff erent lock file than
   /// the one previously read if there is a race.

diff  --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp
index 10181192afbd..5c6508c3b007 100644
--- a/llvm/lib/Support/LockFileManager.cpp
+++ b/llvm/lib/Support/LockFileManager.cpp
@@ -290,7 +290,8 @@ LockFileManager::~LockFileManager() {
   sys::DontRemoveFileOnSignal(UniqueLockFileName);
 }
 
-LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
+LockFileManager::WaitForUnlockResult
+LockFileManager::waitForUnlock(const unsigned MaxSeconds) {
   if (getState() != LFS_Shared)
     return Res_Success;
 
@@ -301,9 +302,6 @@ LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
   Interval.tv_sec = 0;
   Interval.tv_nsec = 1000000;
 #endif
-  // Don't wait more than 40s per iteration. Total timeout for the file
-  // to appear is ~1.5 minutes.
-  const unsigned MaxSeconds = 40;
   do {
     // Sleep for the designated interval, to allow the owning process time to
     // finish up and remove the lock file.


        


More information about the llvm-commits mailing list