summaryrefslogtreecommitdiff
path: root/lib/Support/LockFileManager.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2014-04-06 03:19:31 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2014-04-06 03:19:31 +0000
commit20384a5583ef97644120f819e3d403652d36825d (patch)
tree187f0afe2e953b27f65e1b1451410cb9d363448e /lib/Support/LockFileManager.cpp
parentec37734d3c914411f623fc04d037bb80ff95e220 (diff)
downloadllvm-20384a5583ef97644120f819e3d403652d36825d.tar.gz
llvm-20384a5583ef97644120f819e3d403652d36825d.tar.bz2
llvm-20384a5583ef97644120f819e3d403652d36825d.tar.xz
[Support] Modify LockFileManager::waitForUnlock() to return info about how the lock was released.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205683 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/LockFileManager.cpp')
-rw-r--r--lib/Support/LockFileManager.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Support/LockFileManager.cpp b/lib/Support/LockFileManager.cpp
index cd1cbcb2c5..fb07801a14 100644
--- a/lib/Support/LockFileManager.cpp
+++ b/lib/Support/LockFileManager.cpp
@@ -43,8 +43,11 @@ LockFileManager::readLockFile(StringRef LockFileName) {
std::tie(Hostname, PIDStr) = getToken(MB->getBuffer(), " ");
PIDStr = PIDStr.substr(PIDStr.find_first_not_of(" "));
int PID;
- if (!PIDStr.getAsInteger(10, PID))
- return std::make_pair(std::string(Hostname), PID);
+ if (!PIDStr.getAsInteger(10, PID)) {
+ auto Owner = std::make_pair(std::string(Hostname), PID);
+ if (processStillExecuting(Owner.first, Owner.second))
+ return Owner;
+ }
// Delete the lock file. It's invalid anyway.
sys::fs::remove(LockFileName);
@@ -171,9 +174,9 @@ LockFileManager::~LockFileManager() {
sys::fs::remove(UniqueLockFileName.str());
}
-void LockFileManager::waitForUnlock() {
+LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
if (getState() != LFS_Shared)
- return;
+ return Res_Success;
#if LLVM_ON_WIN32
unsigned long Interval = 1;
@@ -211,7 +214,7 @@ void LockFileManager::waitForUnlock() {
// available now.
if (LockFileGone) {
if (sys::fs::exists(FileName.str())) {
- return;
+ return Res_Success;
}
// The lock file is gone, so now we're waiting for the original file to
@@ -234,7 +237,7 @@ void LockFileManager::waitForUnlock() {
// owning the lock died without cleaning up, just bail out.
if (!LockFileGone &&
!processStillExecuting((*Owner).first, (*Owner).second)) {
- return;
+ return Res_OwnerDied;
}
// Exponentially increase the time we wait for the lock to be removed.
@@ -257,4 +260,5 @@ void LockFileManager::waitForUnlock() {
);
// Give up.
+ return Res_Timeout;
}