Skip to content

Commit e05e219

Browse files
committed
[LockFileManager] Make default waitForUnlock timeout a parameter, NFC
Patch by Xi Ge!
1 parent 7a38468 commit e05e219

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

llvm/include/llvm/Support/LockFileManager.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ class LockFileManager {
7777
operator LockFileState() const { return getState(); }
7878

7979
/// For a shared lock, wait until the owner releases the lock.
80-
WaitForUnlockResult waitForUnlock();
80+
/// Total timeout for the file to appear is ~1.5 minutes.
81+
/// \param MaxSeconds the maximum wait time per iteration in seconds.
82+
WaitForUnlockResult waitForUnlock(const unsigned MaxSeconds = 40);
8183

8284
/// Remove the lock file. This may delete a different lock file than
8385
/// the one previously read if there is a race.

llvm/lib/Support/LockFileManager.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ LockFileManager::~LockFileManager() {
290290
sys::DontRemoveFileOnSignal(UniqueLockFileName);
291291
}
292292

293-
LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
293+
LockFileManager::WaitForUnlockResult
294+
LockFileManager::waitForUnlock(const unsigned MaxSeconds) {
294295
if (getState() != LFS_Shared)
295296
return Res_Success;
296297

@@ -301,9 +302,6 @@ LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
301302
Interval.tv_sec = 0;
302303
Interval.tv_nsec = 1000000;
303304
#endif
304-
// Don't wait more than 40s per iteration. Total timeout for the file
305-
// to appear is ~1.5 minutes.
306-
const unsigned MaxSeconds = 40;
307305
do {
308306
// Sleep for the designated interval, to allow the owning process time to
309307
// finish up and remove the lock file.

0 commit comments

Comments
 (0)